A family of Microsoft relational database management systems designed for ease of use.
DJSteele, MVP wrote in
news:*** Email address is removed for privacy ***
m:
In addition to what the others have told you, OpenQuery really
isn't an appropriate way to run action queries.
Instead, try:
Private Sub Form_AfterInsert()
Dim db As DAO.Database
totalpayment (Me!invno) 'totals the payment amount
Set db = CurrentDb
db.QueryDefs(("updatepartial_payment").Execute dbFailOnError
If Forms!frmupdateinvoice2!Total <= 0 Then
db.QueryDefs("qryupdatepaidinfulldate").Execute dbFailOnError
End If
Set db = Nothing
End Sub
I"ve never really understood why anyone would execute queries via
the QueryDefs collection, instead of just directly. This is going to
work just fine:
CurrentDB.Execute("updatepartial_payment", dbFailOnError)
I also don't understand why there is a need in the code above to
assign a database variable. It would be a correct thing to do if the
second use of it were something like this:
Debug.Print db.OpenRecordset("SELECT @@IDENTITY")(0)
...but there is no necessary dependency between the two uses, so
CurrentDB should be just fine. The queries are going to take a lot
longer to run than it will take to initialize CurrentDB a second
time.
David W. Fenton http://www.dfenton.com/ contact via website only http://www.dfenton.com/DFA/