Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate one field based on two other fields? 1

Status
Not open for further replies.

dpav29

Technical User
Aug 3, 2001
155
0
0
US
Field 3 is required if fields 1 & 2 are not equal. One the lostfocus event of field three, I want the validation code to run. . .not sure what to do. Something like this (you'll see I'm very new to VB. . .don't know how to deal with ANDIF and Not=):

Private Sub Notes_LostFocus()
Dim StrMsg As String
If IsNull (Notes) AndIf Field1 is not equal to field2
blah blah blah I'm clueless Then
StrMsg = "You must enter your case notes before adding a new DRG", vbOK

I want the OK button to set focus on Field 3.

Please help!
 
txtField3_LostFocus()
If nz(txtField3,"")="" AND _
txtField2 <> txtField2 then 'nz tests for Null and &quot;&quot;
msgbox strMsg
txtField3.SetFocus
endif
 
txtField3_LostFocus()
If nz(txtField3,&quot;&quot;)=&quot;&quot; AND _
txtField1 <> txtField2 then 'nz tests for Null and &quot;&quot;
msgbox strMsg
txtField3.SetFocus
endif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top