How to prevent pop-up box

J

John Michael

I am updating a table with an SQL statement in a VBA module when you click a
command button on a form that closes the form after doing some background
stuff.

When it updates the table, it then pops open a form asking if you approve of
the update before closing the form.

How can you suppress this pop-up box.

Thanks
John Michael
 
N

Nick Coe \(UK\)

Use the SetWarnings method of the DoComd object. Just
before your SQL executes use DoCmd.SetWarnings :-

DoCmd.SetWarnings False

Do your SQL stuff

DoCmd.SetWarnings True

It is good practice to turn them back on again.
 
D

Douglas J. Steele

The nice thing about using the Execute method is that you can trap for
errors as well:

CurrentDb.Execute strSQL, dbFailOnError
 
N

Nick Coe \(UK\)

Doug,

Doesn't using CurrentDb imply a late bind to DAO?

Not that that's bad, I'm just curious.
 
D

Douglas J. Steele

To be honest, I'm not sure. It works in Access 2000 and 2002 without setting
a reference, so it may well be late bound.
 

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

Similar Threads


Top