validate data based on a different field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a list box. Based on what is selected in the list box, I want 4 other
fields to be answered by the user. Would like to send a message to user and
not accept record until the other fields are populated.
 
I have a list box. Based on what is selected in the list box, I want 4 other
fields to be answered by the user. Would like to send a message to user and
not accept record until the other fields are populated.

I am assuming that by accept you mean save....Try this....

If (isnull(field1) or isnull(field2) or isnull(field3) or
isnull(field4)) then
call msgbox("Error........Please make sure that .....")
exit sub
end if

You can also choose to have 4 if statements which would allow you to
have specific error messages....
 
Leslie said:
I have a list box. Based on what is selected in the list box, I want 4 other
fields to be answered by the user. Would like to send a message to user and
not accept record until the other fields are populated.

Use the form's BeforeUpdate event to check th elist box's
value and then check the other 4 textboxes:

Sub Form_BeforeUPdate (. . .
Select Case Me.listbox
Case v1,v2,v5 'need to check other text boxes
If IsNull(t1) Or IsNull(t2) Or . . . Then
MsgBox "your message"
Cancel = True
End If
End Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top