Suppress parameters request

G

Goblin

Hi,

I need to execute a batch of queries (read from a file) and log the errors
in another file.
Im using the DoCmd.RunSQL command, but when a query is not correct (for
example, missing quotes) Access stop the macro processing and ask for the
missing parameter.

Is it possible to suppress this behaviour and just have an error as result
of the wrong query?
I've already tried with DoCmd.SetWarnings False but this seems not to work.

I'm using Access 2000.

Thanks.
 
D

Douglas J. Steele

Rather than using RunSQL, try using the Execute method of the Database
object, with a parameter of dbFailOnError.

That will raise an error that you can trap and continue processing however
you like.
 
G

Goblin

Douglas, Allen

thanks for your help. I've really appreciated.
Effectively the Execute method works better, and works as I expected.
Also, the error management is really easier to implement.
The only remark I can do is that in the documentation I found that
CurrentDb.Execute is suggested instead than using DBEngine(0)(0).Execute.
Any suggestion regarding this point?
 
A

Allen Browne

CurrentDb is fine.

Swings and roundabouts. dbEngine(0)(0) is already open, so faster, though it
may not be up to date.

Using CurrentDb clears all the collections, and then creates a new object
variable, and points it at the currently open database. It is guaranteed to
be up to date, but takes longer to open, and has a limited lifetime. It does
need to be explicitly de-referenced, or you can run out of "databases."

So, CurrentDb is safer, provided you reference and dereference it properly.
If the database structure is static (not creating/destroying tables),
dbEngine(0)(0) is just as good and faster.
 

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