Error Messages

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.
 
R

Roxie Aho

-----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.
.
 
R

Roxie Aho

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
 
K

Ken Snell

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top