Validation Rule Problem...

Dragonchaser

Registered User.
Local time
Today, 01:39
Joined
May 15, 2007
Messages
31
Afternoon All,

I've been having problems getting a field in a form to check the value in another field (in the same form) based my Validation Rule.
Example: When the user enters "Item 1" into Field1 it checks to see if the value "Item 2" is entered into Field2, because if Field1 has "Item 1" then Field2 must have "Item 2" as a value.
I would like it to work both ways. (Field2 checks Field1 for the value the same way.)
I've tried a few IIf functions combo and many straight expressions to no avail.
I'm sure there's an expression I'm not using that solves this problem fairly easily.
Can anyone help how me the way? :confused:

All the best,

Mark
 
And what would you like to happen if your rules are violated?
 
Have the user select/enter the value correct value and not be allowed to continue until the fields match. The Validation Text states that "When using Item 1, Item 2 must used as well."
 
This should do it!

Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Field1 = "Item 1" And Field2 <> "Item 2" Then
  MsgBox ("Field1 and Field2 Do Not Match! Please Check your Data and Re-enter!")
  Cancel = True
  Field2.SetFocus
End If
If Field1 <> "Item 1" And Field2 = "Item 2" Then
  MsgBox ("Field1 and Field2 Do Not Match! Please Check your Data and Re-enter!")
  Cancel = True
  Field1.SetFocus
End If
End Sub

Good Luck!
 

Users who are viewing this thread

Back
Top Bottom