Standard Error Message

G

Guest

I have two forms that have several required fields. I have set validation
rules for the required fields on both forms.

For one form, the validation rules are working as I expect them to (display
a pop-up box to the user telling them what field must be filled out and
returning the user to the form before saving).

For the other form, the validation rules are not working as I expect them
to. The pop-up box does not appear and instead, the standard error message
that Access displays is appearing (and upon closing that, the Access message
appears stating that the record can't be saved).

Any ideas on how I can make the 2nd form work the same way that my 1st form
is working??

Thank you in advance!
 
G

Guest

In looking at this further, I have found that the problem I am encountering
only happens when I'm trying to save a new record. My validation rules seem
to work fine if the record is existing and is just being edited (if someone
deletes the value in an existing record on the form.)

Anyone know how I can get rid of the standard message and display my own on
required fields in new records on my forms?

Thanks again!
 
G

Guest

The standard error messages only appear when your error handling and
validation code do not work. If you have your validation code in the table,
I suggest you remove it from there, and include it on your form. The most
common place is in the Before Update event of the control. If you have any
cross field validation, that is ususally in the Before Update event of the
form.
 
G

Guest

I am totally new at this and didn't realize that I am able to do that. I
have found the BeforeUpdate event but am unsure of what the code should look
like. Any suggestions? Thanks in advance!!!
 
G

Guest

I don't know what your rule is, but the Before Update event is the right
place to put it. There are two types of Before Update events. One for each
control on the form and one for the form itself. You use the control Before
Update to do whatever you want to check the validity of the data entered or
take any action based on what was entered in the control. The form's Before
Udate is useful to take action before the data in the form is written to the
tables. A basic example would be if you have a text box that has to have
data in it and the length of the data entered must be between 3 and five
characters long. We will call this control txtSomeStuff.

If IsNull(Me.txtSomeStuff) Then
MsgBox "Data is Required for this Field"
Cancel = True
ElseIf Len(Me.txtSomeStuff) < 3 or Len(Me.txtSomeStuff) > 5 Then
MsgBox "Entry must be between 3 and 5 characters long"
Cancel = True
End If

Notice the Cancel = True. This cancels the update for the control and
leaves the focus on the control so you can correct it.
 

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

Similar Threads


Top