Form Validation

Vav

Registered User.
Local time
Today, 16:13
Joined
Aug 29, 2002
Messages
36
Have not worked in Access for a while.

I need to validate a text box on a form to make sure that it is not empty when the form closes. Only problem is i can't remeber which declaration is should come under.

I know it is not "Form" "Unload" cause that just checks to see if the current forms txt box is empty.

Any direction would be nice.

Peter Vav
 
Not sure if i explained it correctly

Hi Rich, thanks for the suggestion but it does not seem to work.

Here is an example of what is happeneing.

Lets say i have five records.

records 1,2,3,5 all have the txt boxes filled in properly.

But record 4 does not.

I want to validate the form as i shift between forms. IE if i am on record 4 and then move to the 5th record i want a msgbox to pop up.

Right now i have a simple line of code that does a quick check on all the text boxes on the Form Unload but that does not work effectivly.

Thanks

Peter Vavasour
 
As Rich said, move your code to the BeforeUpdate event of the form. Don't forget to cancel the update event if there are any errors.

Code:
If IsNull(SomeField) Then
    Cancel = True
    MsgBox "Some Error Message", vbOKOnly
End If

This is NOT going to fix bad data that you already have stored. You'll need to fix that yourself. This will prevent new bad data from being added.
 

Users who are viewing this thread

Back
Top Bottom