RE: Standard Error Message
- From: Klatuu <Klatuu@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 19 Aug 2005 06:20:04 -0700
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.
"monkey" wrote:
> 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!!!
>
> "Klatuu" wrote:
>
> > 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.
> >
> > "monkey" wrote:
> >
> > > 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!
> > >
> > > "monkey" wrote:
> > >
> > > > 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!
.
- References:
- Standard Error Message
- From: monkey
- RE: Standard Error Message
- From: monkey
- RE: Standard Error Message
- From: Klatuu
- RE: Standard Error Message
- From: monkey
- Standard Error Message
- Prev by Date: Re: How do I use a list box to update a record in a table
- Next by Date: Re: How do I link a text list to a set of values?
- Previous by thread: RE: Standard Error Message
- Next by thread: Help Request
- Index(es):
Relevant Pages
|