Run time error 3146

  • Thread starter Thread starter JP Jones
  • Start date Start date
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?
 
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.
 
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.
 
Back
Top