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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validation Rule/Code between combo box & text field

Status
Not open for further replies.

LeiDBug007

Technical User
Oct 15, 2003
33
US
Greetings Experts,

We've got a combo box field (cfCeaseDesistLtrMailed) that has a "YES/NO" choice for the user to indicate if a particular letter was sent. Right after that field, we've got a date field (cfDateMailed) where the user has to enter the date the letter was sent.

I want to run a validation rule (or code) that says if the user chooses "YES" in the letter sent combo box field, a validation text (or message box) will indicate saying something like "You must enter the date the letter was sent." Of course if it's a "NO", then it's not applicable.

Also, once they click OK from the message, we need it to focus back to the date field (cfDateMailed). Then once entered, they can proceed w/the rest of the form. They cannot proceed unless a date is entered.

We just want to make it clean so that if they say "YES I sent the letter"... then logically they should put the date they sent the letter. We don't really want to depend on training the staff to make sure they put one -- we want to MAKE SURE THEY PUT ONE.

HELP! Thanx so much!

~LeiDBug007
 
I would use a check box for the yes/no field. The value of the check box is either yes (-1) or no (0), make sure the triple state property is set to 'No'.

In the AfterUpdate event of the check box write:

cfDateMailed.SetFocus

This will set the focus to the date field. I wouldn't enforce the entry of a date value for a checked CeaseDesistLtrMailed until the close of the form, it can get messy trying to force a particular order of operations on a form when the user has the ability to fill out the form in any order they choose. But that decision is yours to make.

However the code to enforce this is simple:

If CeaseDesistLtrMailed = True then
msgbox "You must enter a date sent when checking the 'Letter Mailed' check box."
cfDateMailed.SetFocus
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top