Useful error message?

  • Thread starter Thread starter Bruce
  • Start date Start date
B

Bruce

I would have thought this was an easy one, but since this
is Microsoft, the term doesn't apply. I have record
navigation buttons on a form. When I reach the last
record I get a nearly useless error message. I have
located the offending code, and have changed it to
MsgBox Err.Description, vbInformation, "Last record" which
at least changes the title bar, but how do I change "You
can't go to the specified record"? The Access "Help"
files say that after another comma I would add the "String
expression that identifies the Help file to use to provide
context-sensitive Help". All I want to do is to change a
few words.
 
I would have thought this was an easy one, but since this
is Microsoft, the term doesn't apply. I have record
navigation buttons on a form. When I reach the last
record I get a nearly useless error message. I have
located the offending code, and have changed it to
MsgBox Err.Description, vbInformation, "Last record" which
at least changes the title bar, but how do I change "You
can't go to the specified record"? The Access "Help"
files say that after another comma I would add the "String
expression that identifies the Help file to use to provide
context-sensitive Help". All I want to do is to change a
few words.

You should be able to write your own message by trapping the error in
the Form's Error Event.

If Err = XXXX Then
MsgBox "You can't do that!!"
End If
acDataErrContinue

I handle it a bit differently when I use my own navigation command
buttons.
Code the Form's Current event:

CmdPreviousRecord.Enabled = Not Me.CurrentRecord = 1
CmdNextRecord.Enabled = Me.CurrentRecord = 1 Or Me.CurrentRecord <
Me.Recordset.RecordCount

The user can't go from record 1 to 0, and can't go past the last
record as the button's are disabled.
 
I added a little (I took a guess, and it seems to work) to
disable the buttons when there are no records. I use the
form to track document reviews. If there are no current
(ongoing) reviews, there will be no records. In that case
I want the navigation buttons disabled.
cmdGoToPrevious.Enabled = Not Me.CurrentRecord = 1
cmdGoToNext.Enabled = (Me.CurrentRecord = 1 And
Me.Recordset.RecordCount > 1) Or Me.CurrentRecord <
Me.Recordset.RecordCount
The error message to which I referred is in the code
behind the GoToNext/Previous navigation buttons. There is
a line of code (default when the Control Button Wizard is
used) that is something like "On Error GoTo
Err_cmdGoToNext_Click. Then farther down in the code is a
line that says
Err_cmdGoToNext_Click:
MsgBox Err.Description
Resume Exit_cmdGoToNext_Click
If I change the line to MsgBox Err.Description,,"Title"
Bar, I will see Title Bar in the title bar for the message
box when I try to past the last record. I would think it
is possible to add a line of text for the body of the
messageto the end of this line of code somehow , but it
seems that is not so.
 
Back
Top