top of page

SQL To/From VBA Converter

Many Access developers regularly create queries in SQL view then convert them to VBA strings or vice versa. It can be very tedious performing these conversions: adding or removing line continuations, converting single quotes (apostrophes) and double quotes to ensure the code remains valid.

This utility started as a simple SQL to VBA converter. I then added the reverse functionality (VBA to SQL) and many additional features. In addition, the utility allows you to expand/indent SQL strings, create test queries and example code from VBA strings, checks for valid SQL/VBA and much more. It can be a huge time saver for Access developers.

Recently, I converted it to an Access add-in so it is even easier to use with your applications.

However, it can still be used as a standalone application if preferred.


The utility is available as a fully functional, free 32/64-bit ACCDE add-in from https://www.isladogs.co.uk/sql-to-vba-back-again. This article includes full details of all features.


For anyone interested in knowing how it works, the source code is available to purchase. The introductory price is £30 GBP (until 31 August 2024). After that, it will cost £40 GBP.


NOTE: Other similar converters are available online. For example, an excellent Access to T-SQL converter is available at: https://accessusergroups.org/sql-converter/

483 views5 comments

Recent Posts

See All

5 comentarios


Great idea for a useful tool, Colin! I will have to try this out. Thank you also for mentioning the AccessUserGroups.org tool. Note that this tool also has a VBA tab on the right side that allows Access SQL to VBA conversion.

Me gusta

Just tested again in an old version dating from 2021 and could replicate the issue you described on the final field if it ended in 'or' or 'and'. Unfortunately nobody ever reported that to me before.


Neither cause an issue in the latest version. I also checked with a field ending in 'not' which was also OK. Finally I tested using a capital O as in ColOr and it was fine:

After conversion, I had strSQL = "SELECT Tutor, Humor, ColOr FROM tblBeavOr;"

Similarly this was fine after conversion: SELECT Tutor, Humor, ColOr, kNot, IslAnd FROM tblBeavOr;


So yes . . . I appear to have fixed it in the latest version without ever realising there was an issue. 😁

Me gusta

Garry Smth
Garry Smth
17 ago

I utilize this and am deeply appreciative of your contributions to the Access Developers community. I've encountered a quirk: when "or" is at the end of a field name, the resulting code interprets it as an OR statement. Has this issue been addressed?


Thank you again for the numerous occasions it has been a time-saver.


Garry

Me gusta
Garry Smth
Garry Smth
18 ago
Contestando a

I will try to reproduce the instance if I can find it sometime this week and get back to you Colin.

Me gusta
bottom of page