Hi,
I'm having an issue with getting some code to work. I have a form that has a command button that updates a table. The code is listed below:
Private Sub Add_Record_Click()
On Error GoTo Err_Add_Record_Click
DoCmd.GoToRecord , , acNewRec
Exit_Add_Record_Click:
Exit Sub
Err_Add_Record_Click:
MsgBox Err.Description
Resume Exit_Add_Record_Click
End Sub
Here is my issue: I don't want the record to be updated if two parts of the form are not equal. The code I'm trying to enter is below:
If NZ (Me.Cartons) <> NZ (Me.Carton Total) Then
Msgbox "Error Message", vbcritical
Cancel = True
End If
It seems to me I should be able to enter that code before the first one. In practice it is not working that way. It is telling me I have a variable undefinded. Any thoughts?
Thanks
Eddie
I'm having an issue with getting some code to work. I have a form that has a command button that updates a table. The code is listed below:
Private Sub Add_Record_Click()
On Error GoTo Err_Add_Record_Click
DoCmd.GoToRecord , , acNewRec
Exit_Add_Record_Click:
Exit Sub
Err_Add_Record_Click:
MsgBox Err.Description
Resume Exit_Add_Record_Click
End Sub
Here is my issue: I don't want the record to be updated if two parts of the form are not equal. The code I'm trying to enter is below:
If NZ (Me.Cartons) <> NZ (Me.Carton Total) Then
Msgbox "Error Message", vbcritical
Cancel = True
End If
It seems to me I should be able to enter that code before the first one. In practice it is not working that way. It is telling me I have a variable undefinded. Any thoughts?
Thanks
Eddie