Follow Us:

Call us:  (306) 986-8888

SQL Tips for Microsoft Access VBA

SQL Tips for Microsoft Access VBA

I find myself writing more and more code in VBA to handle SQL updates and inserts lately.  A great tip for doing this is to create a query in Access first, change it to an update or append query as needed, then switch it to SQL view….voila!  You have the almost perfect code needed to insert into your VBA event.  Modify the syntax to conform to VBA (usually involves a little bit of clean up with quotes and extra words).  Then declare a variable like strsql as string, and set the new code with a line like strsql = ….then add a docmd.runsql strsql and your set!

This technique has saved me countless hours figuring out the right syntax to get rid of slow queries and move to cleaner faster VBA.  I also turn off warnings before running these commands and turn them on again after.  But that’s another blog!

admin
No Comments

Sorry, the comment form is closed at this time.