How to convert queries to vba code?

P

Pepocles

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!
 
M

MChrist

I like to use some thing like:

dim strSQL as string

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

Mark
 
T

Tim Ferguson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top