Make it a condition that if a check box is not ticked, make a field required?

U

Ultraviolet47

Hi all

I have a membership database-people can be contact vai email or post.

On my form I have an email field and a "postal" checkbox. If they want
email contact, they fill in the email field and leave the checkbox
unticked. If they want postal contact, they tick the box and leave
email field blank

However, I'm getting a few blank emails in my queries that return
everyone who did not select postal contact-i.e people are selecting
email contact and not entering an email address.

Is there any way I can make it a condition that if the postal box is
not ticked, make it a requirment to fill in the email field before
saving the form?

Thank guys (3rd post-I need help! lol!)
 
D

Douglas J. Steele

In the form's BeforeUpdate event, put logic along the lines of:

Private Sub Form_BeforeUpdate(Cancel As Integer)

If Me!MyCheckbox = True Then
If Len(Me!MyTextbox & vbNullString) = 0 Then
MsgBox "You forgot to fill in your e-mail address"
Cancel = True
End If
End If

End Sub

(replace MyCheckbox and MyTextbox with the appropriate names)
 

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