REQUIRED field(s) in FORMS

G

Guest

I want a field on my FORM to have data REQUIRED to be entered. It's a COMBO
BOX with a drop down list of options. I want the user to HAVE TO select one
of the options in the drop down box. If the user doesn't select one of the
options in the drop down box, then I don't want the user to be able to go to
the next field.

I went into the TABLE for the field (BENEFICIARYNAME). The DATA TYPE under
the field BENEFICIARYNAME says "text," yet I have it as a COMBO BOX for the
FORM (I don't know if that matters...the form displays the info I need).
Anyhow, I changed the REQUIRED line to read YES.

In the FORM, the COMBO BOX has the CONTROL SOURCE as BENEFICIARYID, not
BENEFICIARYNAME (yet the info displayed is the NAME and not the ID). The ROW
SOURCE TYPE is TABLE/QUERY and the ROW SOURCE is BENEFICIARIES QUERY.

When I go into the BENEFICIARIES QUERY there's no option to make anything
REQUIRED.

Also, while in the TABLE, do I need to do anything with the VALIDATION RULE?
I would like an error message displayed if the user does NOT select one of
the drop down options.
 
R

Rick Brandt

smags said:
I want a field on my FORM to have data REQUIRED to be entered. It's
a COMBO BOX with a drop down list of options. I want the user to
HAVE TO select one of the options in the drop down box. If the user
doesn't select one of the options in the drop down box, then I don't
want the user to be able to go to the next field.

I went into the TABLE for the field (BENEFICIARYNAME). The DATA TYPE
under the field BENEFICIARYNAME says "text," yet I have it as a COMBO
BOX for the FORM (I don't know if that matters...the form displays
the info I need). Anyhow, I changed the REQUIRED line to read YES.

Okay so far, but making the field required will only raise an error when the
user saves the record. They will still be able to tab into and out of the
ComboBox without making an entry. Once they make an entry though they will not
be allowed to clear it and if they don't make a selection they will not be able
to leave the record or close the form without cancelling the record or making an
entry in the Required field. This is the recommended approach to take.
In the FORM, the COMBO BOX has the CONTROL SOURCE as BENEFICIARYID,
not BENEFICIARYNAME (yet the info displayed is the NAME and not the
ID). The ROW SOURCE TYPE is TABLE/QUERY and the ROW SOURCE is
BENEFICIARIES QUERY.

It is very common for ComboBoxes and ListBoxes to display one value while
storing another. Your current setup is again the correct way to set it up.
When I go into the BENEFICIARIES QUERY there's no option to make
anything REQUIRED.

Correct. Required fields are determined at the Table level and any Qery based
on the Table will inherit that same rule. The Query is merely a "window" on the
Table after all.
Also, while in the TABLE, do I need to do anything with the
VALIDATION RULE? I would like an error message displayed if the user
does NOT select one of the drop down options.

A Validation rule will not work here for a couple reasons. The error for
"Required" would fire before the validation rule anyway and validation rules
only kick in when the user actually enters something, not when they fail to do
so. The built in error message for a missing Required field is pretty easy to
understand, but if you wanted a custom one you could check for problems in the
BeforeUpdate event of the form and display any message you want.
 
G

Guest

The problem is that I have REQUIRED set to YES, but when I test it no errors
arise. What am I doing wrong? I can leave the field blank with no problems
saving the record.
 
R

Rick Brandt

smags said:
The problem is that I have REQUIRED set to YES, but when I test it no
errors arise. What am I doing wrong? I can leave the field blank
with no problems saving the record.

Do you have a default value assigned at the table level or on the form? Do
you have "Allow Zero Length Strings" set to Yes at the table level? Are you
looking at records that were created before the Required = Yes was set? I'm
not sure if the rule will be applied to existing records.
 

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