Form Required Field Question

J

josh

I have a form that gives the user the option of selecting
a department from 2 different check box options. I was
wondering if there is any way to require that the user
check at least 1 of the boxes. I know how to require 1
field to be filled in, but I'm not sure how to require
that either "Field1" or "Field2" is filled in. Thanks
 
R

Rick Brandt

josh said:
I have a form that gives the user the option of selecting
a department from 2 different check box options. I was
wondering if there is any way to require that the user
check at least 1 of the boxes. I know how to require 1
field to be filled in, but I'm not sure how to require
that either "Field1" or "Field2" is filled in. Thanks

This should be one field controlled with an option group. You store a 1 to represent
one department and a 2 to represent the other. Then you make that one field a
required field as normal.
 
J

JohnFol

If this is an option group the selection is mutually exclusive so only 1
dept can be used. Josh has said he is using check boxes which according to
Windows design rules would allow more than 1 department.
Josh, go with Rick's comments if only 1 department can be selected,
otherwise you need to write some code on the before update event.

If ChkDept1.Value or chkDept2.Value then
'We are ok
Else
'Do your screen / user prompts here
End if
 
V

Van T. Dinh

There were some Access bugs (in A2K, I think) associated with CheckBox
values used in Boolean expressions for If statement this way. To avoid the
bug from occurring, use explicit comparison like:

If (ChkDept1.Value = True) OR (chkDept2.Value = True) Then
....
 
R

Rick Brandt

JohnFol said:
If this is an option group the selection is mutually exclusive so only 1
dept can be used. Josh has said he is using check boxes which according to
Windows design rules would allow more than 1 department.
Josh, go with Rick's comments if only 1 department can be selected,
otherwise you need to write some code on the before update event.

If ChkDept1.Value or chkDept2.Value then
'We are ok
Else
'Do your screen / user prompts here
End if

You're right. I didn't consider that checking both departments might be required. I
would then use John's method. If you really wanted it enforced at the table level I
suppose an option group with a third value for "Both Departments" could be used.
Otherwise a Table-Level validation rule might be possible. I'm not sure because
validation rules at the table level are more restrictive in what you can do than they
are at the form level and I haven't used them much.
 

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