validate data based on a different field

L

Leslie

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.
 
C

crawford.francis

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....
 
M

Marshall Barton

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
 
Top