O
ofarah
I have created command buttons in my form and I have customized error
messages. The problem is, I am getting the same error number for
different types of error from the command buttons. I have some required
fields in my form. For example, I have a Previous command button. I am
getting the same error when I click on Previous on the first record and
when I click Previous while adding a new record but haven't filled the
required fields.
I was hoping that I will get different errors so that I can see if the
error message should be "This is the first record" or "Please fill the
required fields". I am getting error number: 2105 in both cases.
Following is the code that I am using to check the error number:
Private Sub Previous_Click()
On Error GoTo Err_Previous_Click
DoCmd.GoToRecord , , acPrevious
Exit_Previous_Click:
Exit Sub
Err_Previous_Click:
'Display a standard error message
MsgBox "Error #: " & Err.Number & " " & Err.Description
Debug.Print Err.Number
End Sub
Am I am doing something wrong here? Any help is appreciated. Thank you
messages. The problem is, I am getting the same error number for
different types of error from the command buttons. I have some required
fields in my form. For example, I have a Previous command button. I am
getting the same error when I click on Previous on the first record and
when I click Previous while adding a new record but haven't filled the
required fields.
I was hoping that I will get different errors so that I can see if the
error message should be "This is the first record" or "Please fill the
required fields". I am getting error number: 2105 in both cases.
Following is the code that I am using to check the error number:
Private Sub Previous_Click()
On Error GoTo Err_Previous_Click
DoCmd.GoToRecord , , acPrevious
Exit_Previous_Click:
Exit Sub
Err_Previous_Click:
'Display a standard error message
MsgBox "Error #: " & Err.Number & " " & Err.Description
Debug.Print Err.Number
End Sub
Am I am doing something wrong here? Any help is appreciated. Thank you