isladogs
MVP / VIP
- Local time
- Today, 16:04
- Joined
- Jan 14, 2017
- Messages
- 18,538
Some years ago, the wonderful Allen Browne created a small utility called Sql2vba
See his website: http://allenbrowne.com/ser-71.html
The purpose was to save developer time:
"Rather than typing complex query statements into VBA code, developers often mock up a query graphically, switch it to SQL View, copy, and paste into VBA.
If you've done it, you know how messy it is sorting out the quotes, and the line endings.
Solution: create a form where you paste the SQL statement, and get Access to create the SQL string for you."
I found this so useful that I extended the idea to work in the other direction as well : VBA to SQL so I could easily create & load a query based on VBA code.
Useful for testing when the VBA string is long & complex as shown below
To use this, just copy the form frmSql2vba & the 2 modules modFunctions & modResizeForm to your own database
The latter module contains code originally by Jamie Czernak used to automatically resize forms depending on users' screen resolution.
If you don't want to use that part:
a) omit the module modResizeForm
b) remove the line ResizeForm Me from the frmSql2vba Form_Open procedure
Any comments welcomed.
See post #6 for the latest version
See his website: http://allenbrowne.com/ser-71.html
The purpose was to save developer time:
"Rather than typing complex query statements into VBA code, developers often mock up a query graphically, switch it to SQL View, copy, and paste into VBA.
If you've done it, you know how messy it is sorting out the quotes, and the line endings.
Solution: create a form where you paste the SQL statement, and get Access to create the SQL string for you."
I found this so useful that I extended the idea to work in the other direction as well : VBA to SQL so I could easily create & load a query based on VBA code.
Useful for testing when the VBA string is long & complex as shown below
To use this, just copy the form frmSql2vba & the 2 modules modFunctions & modResizeForm to your own database
The latter module contains code originally by Jamie Czernak used to automatically resize forms depending on users' screen resolution.
If you don't want to use that part:
a) omit the module modResizeForm
b) remove the line ResizeForm Me from the frmSql2vba Form_Open procedure
Any comments welcomed.
See post #6 for the latest version
Attachments
Last edited: