R
Roderick O'Regan
I have a form open ("ordernew") based on a table ("order"). I now
press a Cancel command button halfway through entering data on the
form.
Behind the Cancel button I have the following code which closes the
form without saving. It is then supposed to open the table called
"Codes" to reduce the order number by one.
Dim db As Database
Dim rs As Recordset
Dim pcodevalue As Integer
Set db = CurrentDb
DoCmd.Close acForm, "orderNew", acSaveNo
pcodevalue = DLookup("[Last_Nbr_Assigned]", "Codes",
"[Last_Nbr_Assigned]>999")
Set rs = db.OpenRecordset("Codes", dbOpenTable)
rs.Fields("Last_Nbr_Assigned") = pcodevalue - 1
rs.Update
rs.Close
However, I get a Type Mismatch on this line of code:
Set rs = db.OpenRecordset("Codes", dbOpenTable)
I don't understand why this is happening.
Can anyone help, please?
Roderick
press a Cancel command button halfway through entering data on the
form.
Behind the Cancel button I have the following code which closes the
form without saving. It is then supposed to open the table called
"Codes" to reduce the order number by one.
Dim db As Database
Dim rs As Recordset
Dim pcodevalue As Integer
Set db = CurrentDb
DoCmd.Close acForm, "orderNew", acSaveNo
pcodevalue = DLookup("[Last_Nbr_Assigned]", "Codes",
"[Last_Nbr_Assigned]>999")
Set rs = db.OpenRecordset("Codes", dbOpenTable)
rs.Fields("Last_Nbr_Assigned") = pcodevalue - 1
rs.Update
rs.Close
However, I get a Type Mismatch on this line of code:
Set rs = db.OpenRecordset("Codes", dbOpenTable)
I don't understand why this is happening.
Can anyone help, please?
Roderick