Append query

A

alexasha

Hi,
I have set up several append queries. Is it possible to set to run them
through switchboard. So far I can not find this option.
Thanks
 
W

Wayne Morgan

If you are using the built in switchboard, yes. You will need to create a
Function (not a sub) in a standard module. One of the switchboard options is
to "Run Code". You would call this function from the switchboard. In the
function, you would execute your queries. You could even set them up as a
Transaction so that if any of them fails, they'll all be rolled back
(undone).

To execute the queries in the function:
Dim db As DAO.Database
Set db = CurrentDb
db.Execute "qryMyQuery1", dbFailOnError
db.Execute "qryMyQuery2", dbFailOnError
Set db = Nothing
 
A

alexasha

Thanks.
For some reason I am getting
Compile Error:
Invalid outside procedure
and it highlights
Set db

I am not sure what to do.
 
W

Wayne Morgan

Verify that you have a Reference set for DAO. In the code editor go to
Tools|References and make sure there is a check next to "Microsoft DAO 3.6
Object Library", although I would have expected the DIM statement to fail if
it wasn't there.

Where did you put the code?
 
Top