Multiple Quaries

  • Thread starter Thread starter Malcolm Andersson
  • Start date Start date
M

Malcolm Andersson

Hey.
I've made three quaries in design mode;
Fr-LäggTillDjur - Adds to a table called Djuret
Fr-LäggTillÄgare - Adds to a table called Ägare
Fr-RensaBuffert - Deletes a buffert table I have that temp stores the info
that the previously queries add.

What I want know Is that the queries is triggered in that order when pushing
a button in a form. I am a beginner when it comes to intermediet/advance
queries and VBA.

Thanks In advance
 
You are wanting to make sure that the first action query runs to completion
before the next begins, and so on?

That should be fine if you Execute them like this:
Dim db As DAO.Database
Set db = dbEngine(0)(0)
db.Execute "Fr-LdggTillDjur ", dbFailOnError
db.Execute "Fr-LdggTillDgare ", dbFailOnError
db.Execute "Fr-RensaBuffert ", dbFailOnError
Set db = Nothing

If you want something more than that, you could wrap them in a transaction
so you get an all-or-nothing result. Details and example:
http://members.iinet.net.au/~allenbrowne/ser-37.html
 
Thank you for the fast respons, however I cant seem to get it to work.
This is how the code looks in the VB code for the button;
<--start of code-->
Private Sub Spara_knapp_Click()
On Error GoTo Err_Spara_knapp_Click

Dim db As DAO.Database
Set db = DBEngine(0)(0)
db.Execute "Fr-LäggTillÄgare ", dbFailOnError
db.Execute "Fr-LäggTillDjur ", dbFailOnError
db.Execute "Fr-RensaBuffert ", dbFailOnError
Set db = Nothing

Exit_Spara_knapp_Click:
Exit Sub

Err_Spara_knapp_Click:
MsgBox Err.Description
Resume Exit_Spara_knapp_Click

End Sub

<--end of code-->

I get an error message when I try to execute it:
"User-defined type not defined"
And "Private Sub Spara_knapp_Click()" is highlighted in yellow.

What have I missed?
 
Malcolm,
In the VBE window (Alt - F11), click on Tools, References,
scroll down to Microsoft DAO 3.6 Object Library (oe
whatever version you have), check it, and click OK.
Geof Wyght
 
It worked!
I tip my hat in gratitude

Malcolm
"Geof Wyght" <[email protected]> skrev i meddelandet
Malcolm,
In the VBE window (Alt - F11), click on Tools, References,
scroll down to Microsoft DAO 3.6 Object Library (oe
whatever version you have), check it, and click OK.
Geof Wyght
 
Back
Top