Re: MsgBox Err.description



This is what Bob posted:
If Err.Number = 94 Then
MsgBox "There are no more records for this employee."
Else
End If

This is what I posted:
Err_previousRecord_Click:
If Err.Number = 94 Then
MsgBox "There are no more records for this employee."
Resume Exit_Next_Record_Click
Else
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Next_Record_Click
End If

And this is what you posted:
Err_previousRecord_Click:
MsgBox "There are no more records for this employee."
Resume Exit_previousRecord_Click


I don't know that 94 is the actual error number you're getting. You will have
to step through your code to determine that. The code snippets that Bob and I
posted work.



On Wed, 22 Mar 2006 08:20:33 -0800, Gwen H <GwenH@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:

I copied Bob's code and pasted it into mine, so I know I implemented it
correctly. It didn't matter if I used it on the "nextRecord" or
"previousRecord" button - when I reached the first or last record, no error
messages at all displayed.

I'm using Access 2003, if that makes any difference.

"RD" wrote:

Well, you skipped the "If" part! Bob's suggestion should work perfectly if you
implement it correctly.

Err_previousRecord_Click:
If Err.Number = 94 Then
MsgBox "There are no more records for this employee."
Resume Exit_Next_Record_Click
Else
MsgBox Err.Number & ": " & Err.Description
Resume Exit_Next_Record_Click
End If


On Wed, 22 Mar 2006 07:13:27 -0800, Gwen H <GwenH@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:

Nope, that doesn't work. I was really hoping to do something like this, but
the syntax seems to be wrong since it doesn't work:

Err_previousRecord_Click:
MsgBox "There are no more records for this employee."
Resume Exit_previousRecord_Click

Thanks for taking time to reply!

GwenH

"bob" wrote:

try this:

If Err.Number = 94 Then
MsgBox "There are no more records for this employee."
Else
End If

Bob Galway


"Gwen H" <GwenH@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:27B87054-AAA9-4572-99E7-12EC8B2201EE@xxxxxxxxxxxxxxxx
I have the following code attached to a form navigation button
(nextRecord).
How do I change it so it displays a custom error message? When a user
clicks
on the "Next Record" button, and there are no more records, instead of
getting the standard "You can't go to the specified record" error message,
I
want it to say "There are no more records for this employee." I know I
need
to make the change in the last 5 lines of code, but I'm having trouble
with
the syntax.

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






.



Relevant Pages

  • RE: Prevent 2 Decimal Points Entry in a Textbox
    ... Thank you - Bob ... >> Does anyone have code to allow entry of ONLY one Decimal Point (KeyAscii ... >> Public Sub DecZeroNine ... >> MsgBox Screen.ActiveControl ...
    (microsoft.public.access.modulesdaovba)
  • Re: MsgBox Err.description
    ... MsgBox "There are no more records for this employee." ... How do I change it so it displays a custom error message? ... Private Sub Next_Record_Click ... MsgBox Err.description ...
    (microsoft.public.access.modulesdaovba)
  • Re: Use Re-query and RepaintObject Action
    ... > Exit Sub ... > MsgBox Err.Description ... > employee is add from the add employee form. ...
    (microsoft.public.access.modulesdaovba)
  • Re: MsgBox Err.description
    ... MsgBox "There are no more records for this employee." ... How do I change it so it displays a custom error message? ... Private Sub Next_Record_Click ...
    (microsoft.public.access.modulesdaovba)
  • Re: MsgBox Err.description
    ... MsgBox "There are no more records for this employee." ... How do I change it so it displays a custom error message? ... Private Sub Next_Record_Click ...
    (microsoft.public.access.modulesdaovba)