IsNull

J

Jen

I have a command button that fills in address, etc. information based on the
value selected in a field. (This might seem strange, but there are good
reasons for doing it this way in this case.) So the user selects a party from
the combo box, then can either enter address info or can click the command
button to fill in the most-recently-used data for that party.

This works fine. However, if a party hasn't been selected from the list, I
want to cancel the fill in of data. Currently if you click the command button
while nothing is selected, it still gives the msgbox message that's set to
come up after the update.

I've tried inserting this at the front of the code, but it's not working.
What am I doing wrong?

If IsNull(Forms!Agreements!Party) =True Then
Response = MsgBox("You must choose a party first.", vbOKOnly +
vbExclamation, "Select Party")
Exit Sub
End If
If Forms!Agreements!Party = "" Then
Response = MsgBox("You must choose a party first.", vbOKOnly +
vbExclamation, "Select Party")
Exit Sub
End If

(I've also tried different variations, such as replacing
Forms!Agreements!Party with Me!Party. Still nothing happens - it's as if the
code at the beginning is skipped over.)

Thanks,
Jen
 
J

Jeanette Cunningham

Jen,
put something like this on the enter event for each textbox.

If IsNull(Me.Agreements.Party) Then
Msgbox "You must choose a party first"
DoCmd.CancelEvent
End If

Jeanette Cunningham
 
J

Jeanette Cunningham

Jen,
have just re-read this, it looks like your form is called Agreements,
so the code with Me.Agreements.Party I sent should be changed to:

If IsNull(Me.Party) Then
Msgbox "You must choose a party first"
DoCmd.CancelEvent
End If

Jeanette Cunningham
 

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

Top