Validation

Access_Person

Registered User.
Local time
Yesterday, 22:36
Joined
Aug 18, 2004
Messages
14
In my database when a combo box is changed to a certain value a validation rule is supposed to get turned on in an adjacent text box.

My code works but it lets me tab into the now restricted text box (it's empty) and tab out of it without getting an error message. The only way I can trigger the validation rule is if I write somethig in the text box and then erase it to make it blank. Is it just me or aren't validation rules supposed to be enforced when the user tabs out of a control too? What can I do?

Here's the code:

Code:
Private Sub Resume_PASS_Change()

If Resume_PASS = 0 Then
    
    Forms!Sole_Addition_Form!txtResumeComments.ValidationRule = "Is Not Null"
    
Else
    Forms!Sole_Addition_Form!txtResumeComments.ValidationRule = ""
End If
    
End Sub

:confused:
 
AP,

You don't to use the field's OnChange event, that'll only fire on each
individual character the user types into that field.

You should use the forms BeforeUpdate event:

Code:
If IsNull(Me.txtResumeComments) Then
   MsgBox("Hey! Enter it.")
   Cancel = True
End If

Then using the AfterUpdate event of the combo, clear the field,
or whatever.

Wayne
 
Thanks a bundle!

At first it didn't work but it set me of on a path of "Access Visual Basic self discovery".

I ended up (after an hour or so of trying numerous dead ends) using

DoCmd.CancelEvent

due to the fact that

Cancel=True

prevented any error message from beig shown.
 

Users who are viewing this thread

Back
Top Bottom