Customizing Error msg

mgonzales

Registered User.
Local time
Today, 02:00
Joined
Sep 16, 2009
Messages
44
I have made a couple of my fields required. If you do not enter data into the field an error message appears. How do you customize that error message?
 
You can use the table properties to do this.

There is a validation rule and validation text for that particular field. if you need examples just look click F1 and it will explain further in detail how to use the expressions.
 
Just modify the text in the messagebox to suit your needs:

Code:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
Dim Message As String
 If DataErr = 3314 Then 'Required field is empty
 Message = "You Have Left The Field  “ & Me.ActiveControl.Name & “ Empty and 
  It Must Have Data!” 
  Response = MsgBox(Message, vbExclamation, "Data Required For This Field")
  Response = acDataErrContinue
 End If
End Sub
 
Thank you missinglinq that code worked great. Is there a way that I can make this specific to each field? I have 2 fields that require data and it seems that it only notifies you once you are leaving the (in my case) form entirely. Is there a way to have it prompt you once you leave each field? The validation rule only works if you incorrectly type in data into the field and I have dropdwn lists that are coded to prevent typing into them, but I like how the validation is specific to each field.

Thanks!!!
 
You could put your validation code in the "LostFocus" event of each individual field. Or look into lcook1974's recommendation.
 
Validation for the presence or absence of data has to be done just prior to saving the record, either with code such as I gave you, in conjunction with it being defined as Required, in the table, or with different code in the Form_BeforeUpdate event! Trying to tie it to the field's LostFocus event or OnExit event is useless! What will code in these events accomplish if the user simply never tabs into the field? It will do nothing, of course!

And a user should be able to tab into a field and change their mind about filling it in at that time, as long as they do it before they save the record.

Validation code in the control's OnExit or LostFocus event should be reserved for validating that data entered is correct. Checks here are done to insure that the data is all numeric or all alpha or between 1 and 100 or a date in the future, and so forth.
 
Last edited:
Thank you everyone for your suggestions!:)
The only thing that suited what I needed was the direct code. I just customized it to include both fields.
 

Users who are viewing this thread

Back
Top Bottom