A 2010 Error Message Text

Dick7Access

Dick S
Local time
Today, 12:00
Joined
Jun 9, 2009
Messages
4,321
I have a button that goes to the previous record on my form as I can’t rely on the people doing data entry knowing how to find the little arrows at the bottom. If they get to the first record and try to go back any further the little arrow greys out. My button pulls up the error message “You can’t go to that specified record.” I want to change that and be more specific. I googled it and came up with the following on this forum back in 2011.

Private Sub Form_Error(DataErr As Integer, Response As Integer)

Const INPUTMASK_VIOLATION = 2279
If DataErr = INPUTMASK_VIOLATION Then
MsgBox "There was an input mask violation!"
Response = acDataErrContinue
End If

End Sub

Now my problem is not an input violation but I don’t know now what my violation is called so I can’t google it any further. Anybody know what I should be googleing?


 
I have 2 command buttons, one called cmdNext that has this code onClick:

Private Sub cmdNext_Click()
On Error GoTo Err_cmdNext_Click

DoCmd.GoToRecord , , acNext

Exit_cmdNext_Click:
Exit Sub

Err_cmdNext_Click:
MsgBox "You are already at the last record", , "Access Database v1"
Resume Exit_cmdNext_Click

End Sub


The second button is called cmdPrevious and this code is in my OnClick als:

Private Sub cmdPrevious_Click()
On Error GoTo Err_cmdPrevious_Click

DoCmd.GoToRecord , , acPrevious

Exit_cmdPrevious_Click:
Exit Sub

Err_cmdPrevious_Click:
MsgBox "You are already at the first record", , "Access Database v1"
Resume Exit_cmdPrevious_Click

End Sub

You can customize the message as I have done in the MsgBox quotations
 
Thanks veraloopy, that did it!
 

Users who are viewing this thread

Back
Top Bottom