R
RichW
I have a form that uses buttons and code similar to the following for
navigating through records:
***********************
Private Sub Next_Record_Click()
On Error GoTo Err_Next_Record_Click
DoCmd.GoToRecord , , acNext
Exit_Next_Record_Click:
Exit Sub
Err_Next_Record_Click:
MsgBox Err.Description
Resume Exit_Next_Record_Click
End Sub
***********************
In this example, when the Next Record does not exist, I receive the
following message box:
"You can't go to the specified record."
I use the Immediate Window in an attempt to capture the Error Code
associated with the message box, but the Immediate Window remains blank. I
assume that this message is Error Code 2105.
I then enter the following code into the Forms "On Error" event so as to
customize the message box wording:
***********************
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Const conErrRequiredData = 2105
If DataErr = conErrRequiredData Then
MsgBox ("The record does not exist")
Response = acDataErrContinue
Else
'Display a standard error message
Response = acdatadisplay
End If
End Sub
***********************
But the message box wording does not change.
Why do these error handling procedures fail to produce the expected results?
Appreciate the group's support and guidance.
Regards,
navigating through records:
***********************
Private Sub Next_Record_Click()
On Error GoTo Err_Next_Record_Click
DoCmd.GoToRecord , , acNext
Exit_Next_Record_Click:
Exit Sub
Err_Next_Record_Click:
MsgBox Err.Description
Resume Exit_Next_Record_Click
End Sub
***********************
In this example, when the Next Record does not exist, I receive the
following message box:
"You can't go to the specified record."
I use the Immediate Window in an attempt to capture the Error Code
associated with the message box, but the Immediate Window remains blank. I
assume that this message is Error Code 2105.
I then enter the following code into the Forms "On Error" event so as to
customize the message box wording:
***********************
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Const conErrRequiredData = 2105
If DataErr = conErrRequiredData Then
MsgBox ("The record does not exist")
Response = acDataErrContinue
Else
'Display a standard error message
Response = acdatadisplay
End If
End Sub
***********************
But the message box wording does not change.
Why do these error handling procedures fail to produce the expected results?
Appreciate the group's support and guidance.
Regards,