Validation Rules?

  • Thread starter Thread starter Charles
  • Start date Start date
C

Charles

On a form I have a text box and a combo box. If the user enters data into
the text box then the user must choose a value from the value list of the
combo box next to it. If the user leaves the text box blank then the combo
box must be left blank.

The problem I am having is getting the combo box to require an entry if the
text box is populated. Right now as it stands, the user can enter data into
the text box but the program dosn't require the user to enter data into the
combo box. Any ideas?

I tried using the following formula in the Validation Rule property of the
combo box but it didn't work.

=IIf([TextBox]<>IsNull([TextBox]),"Text 1" Or "Text 2",Is Null)
 
On a form I have a text box and a combo box. If the user enters data into
the text box then the user must choose a value from the value list of the
combo box next to it. If the user leaves the text box blank then the combo
box must be left blank.

The problem I am having is getting the combo box to require an entry if the
text box is populated. Right now as it stands, the user can enter data into
the text box but the program dosn't require the user to enter data into the
combo box. Any ideas?

I tried using the following formula in the Validation Rule property of the
combo box but it didn't work.

=IIf([TextBox]<>IsNull([TextBox]),"Text 1" Or "Text 2",Is Null)

I'd suggest using the BeforeUpdate event of the Form instead:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If IsNull([Textbox]) <> IsNull([combobox]) Then
MsgBox "Either Textbox and Combo box must both be filled," _
& " or both must be empty.", vbOKOnly
Cancel = True
End If
End Sub


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Back
Top