I am getting the following error: "The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing [dbName] from saving the data in the field."
I am trying to increment the value of a field on a form when a new record is created. I know having an Autonumber field will accomplish the same purpose, and in fact we do have such a field. But a second field was needed that could be modified/reset as needed.
I created the following code in the AfterInsert property of the form:
I am trying to increment the value of a field on a form when a new record is created. I know having an Autonumber field will accomplish the same purpose, and in fact we do have such a field. But a second field was needed that could be modified/reset as needed.
I created the following code in the AfterInsert property of the form:
Private Sub Form_AfterInsert()
On Error GoTo Err_AfterInsert
Dim Current_count As Integer
Current_count = DMax("[workrequestnumber]", "basic_data")
Me.WorkRequestNumber = Current_count + 1
Exit_AfterInsert:
Exit Sub
Err_AfterInsert:
MsgBox Err.Description
Resume Exit_AfterInsert
End Sub
The Autonumber appears as soon as I enter any data, but this seconday field shows nothing until I enter data into a second field, and that's when the error occurs.
Any ideas would be greatly appreciated.
On Error GoTo Err_AfterInsert
Dim Current_count As Integer
Current_count = DMax("[workrequestnumber]", "basic_data")
Me.WorkRequestNumber = Current_count + 1
Exit_AfterInsert:
Exit Sub
Err_AfterInsert:
MsgBox Err.Description
Resume Exit_AfterInsert
End Sub
The Autonumber appears as soon as I enter any data, but this seconday field shows nothing until I enter data into a second field, and that's when the error occurs.
Any ideas would be greatly appreciated.