Run time error 3146

J

JP Jones

I have a query that works fine when I increase the odbctimeout value to 600.

I would like to run this same query in code using docmd.runsql however I am
getting run time error 3146.

Is there any easy way for a relative novice to get round this?
 
D

Douglas J. Steele

Why do you want to use DoCmd.RunSQL if you've already got it as a query?


CurrentDb.QueryDefs("NameOfQuery").Execute

or, perhaps better (as it'll raise a trappable error if there's a problem)

CurrentDb.QueryDefs("NameOfQuery").Execute dbFailOnError

This assumes that you have a reference set to DAO. If you're not sure, go
into the VB Editor and select Tools | References from the menu. If Microsoft
DAO 3.6 Object Library isn't one of the selected ones at the top of the
list, scroll through the list until you find it and select it.
 
J

JP Jones

Unfortunately I cannot execute it this way.

I need to pass parameters to the query, and for some reason I have noticed
that the query runs a lot faster if I build the SQL statement in VB.
 

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