How to convert queries to vba code?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi!

I want to convert some queries into vba code... Is this possible? Is there
a routine that could help me doing that? Is there a tutorial at least? Any
suggestions will be better than nothing...

Thanks!
 
I like to use some thing like:

dim strSQL as string

strSQL = "UPDATE mytable SET myfield=NULL"
docmd.runsql strsql

Mark
 
I want to convert some queries into vba code... Is this possible?

Depends what you want to do: if you have a precompiled querydef, then the
easiest and safest thing is just to call it:

Querydefs("MyActionQuery").Execute dbFailOnError

or display it in a datasheet:

DoCmd.OpenQueryDef "MySelectQuery"

or push it into a form:

DoCmd.OpenForm "SomeForm",,, "MySelectQuery"

Sometimes there are reasons to build a SQL string from scratch:

strSQL = "SELECT Something, SomethingElse FROM ..."
Me.RecordSource = strSQL

More info on what you are tring to do please.


Tim F
 
Back
Top