This form used to work fine for me. Yesterday I was trying to do some programming and realized that when I started with this database I was green enough that I didn’t name my tables correctly, so I changed the names of all my tables to simplify things. I used to have the below-mentioned table named USA Orders. After spending most of the day fixing other problems caused by renaming tables, I came upon this problem. When I try to add a new record in the Orders form, I get this message. “Run-time error ‘-2147352567 (80020009) Cannot add record(s); join key of table ‘tblUSAOrders’ not in recordset”. It gives me a Debug option with the line below highlighted. If I click on Help, I get this message. Cannot add record(s); join key of table not in result set. (Error 3348) This is an unexpected error. Please contact Microsoft Product Support Services for more information. Is it really something messed up? I have another form with the exact same code (different table, same scenario as yesterday) that works perfectly.
Private Sub Form_BeforeInsert(Cancel As Integer)
If IsNull(DMax(“OrderID”, “tblUSAOrders”)) Then
Me.OrderID = 1
Else
Me.OrderID = DMax(“OrderID”, “tblUSAOrders”) + 1
End If
End Sub