Error Messages

  • Thread starter Thread starter Bob Cassano
  • Start date Start date
B

Bob Cassano

Is it possible in Access to change the description of an
error message in Access? For example, I am setting a
field to "required". If I don't enter data in
the "required" field, I get a default message that is not
anywhere as easy as saying "Data in this field is
required". Thanks.
 
-----Original Message-----
Is it possible in Access to change the description of an
error message in Access? For example, I am setting a
field to "required". If I don't enter data in
the "required" field, I get a default message that is not
anywhere as easy as saying "Data in this field is
required". Thanks.
.
 
Here's one way.

Use this Event Procedure in the On Exit event of the text
box on your data entry form.

Private Sub Source_Exit(Cancel As Integer)
Dim strA As String
strA = Nz(Me.Source, "")
If strA = "" Then MsgBox ("You screwed up")
DoCmd.GoToControl "Source"
End Sub

Roxie Aho
 
No, but you can intercept the normal ACCESS error process and display your
own error message. There are many ways to do this depending upon the
specific situation.

Easiest way to do it for the "required" operation is to change the table
structure so that the field is not required, and then use the form's
BeforeUpdate event to trap for the absence of an entry:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Len(Me.RequiredControl.Value & "") = 0 Then
Cancel = True
MsgBox "You must enter a value in the ""ControlName"" textbox."
Me.RequiredControl.SetFocus
End If
End Sub
 
Back
Top