Opening a Recordset

  • Thread starter Roderick O'Regan
  • Start date
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
 

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

Top