I use the following code to automatically number entities in a subForm. I keep getting the error "you can't assign a value to this object". It works great in an old Access '97 database I made 2 years ago and converted to Access 2000, but I am making another database with the same form and I get that error. Can somebody see what I am missing. I really appreciate any help.
Option Compare Database
Private Sub Form_BeforeInsert(Cancel As Integer)
On Error GoTo Err_Form_BeforeInsert
Me.txtEntityID = NewEntityID 'This is a Function I use to create the unique entityID'
Me.txtEntityNumber = Nz(DMax("[EntityNumber]", "tblEntities", "[OrderNumber] =" & [txtOrderNumber]), 0) + 1
Exit_Form_BeforeInsert:
Exit Sub
Err_Form_BeforeInsert:
MsgBox Err.Description
Resume Exit_Form_BeforeInsert
End Sub
Option Compare Database
Private Sub Form_BeforeInsert(Cancel As Integer)
On Error GoTo Err_Form_BeforeInsert
Me.txtEntityID = NewEntityID 'This is a Function I use to create the unique entityID'
Me.txtEntityNumber = Nz(DMax("[EntityNumber]", "tblEntities", "[OrderNumber] =" & [txtOrderNumber]), 0) + 1
Exit_Form_BeforeInsert:
Exit Sub
Err_Form_BeforeInsert:
MsgBox Err.Description
Resume Exit_Form_BeforeInsert
End Sub