Making fields mandatory in an Access Form

  • Thread starter Thread starter Al Gavenas
  • Start date Start date
A

Al Gavenas

Is it possible to make a data field in a FORM mandatory?
We have numerous forms that feed information into one
Table. Each form has separate and unique information that
is necessary. We know that making data in the table can be
made mandatory, but would like to use the form to screen
data and information that goes into the table.The way my
form is set up, I have parameters established for a given
field(min/max etc.). Unfortunately, if the data entry
clerk tabs past this field without entering data, the
system does not know information was required in this
particular field. Is it possible to make a data field in a
form require the entry of data?

Thanks for any assistance you can provide.
 
Yes, go to your table in design view. Click on the
general tab. One of the lines says required. If you
change from no to yes, it will require information in the
field. Tell me if its what you needed?
 
Al Gavenas said:
We are trying to use the form to screen the data, rather
than using the table, since it is not always mandatory.
The mandatory option works in the table but different
forms may not require this information.
If this makes any sense.

You can use code in the Form's BeforeUpdate event to check the entries in the form
and if they are not valid then set the Cancel property to true and the record will
not be saved. The user will either have to correct the problem or cancel the record
entirely.
 
If your doing what I think your doing, you will need to
setup VBA code on the AfterUpdate event to check the value
to ensure it meets what ever criteria you establish, then
either insert it or blank the field contents. It would be
something like this:

if(isnull(me!myfield))then
Msgbox "This field requires an entry!"
me!myfield.setfocus
end sub
end if

This would check for a value in the field, then warn the
user if no value present, then set focus back the the
field. The end sub will prevent any further processing,
assuming something else takes place after this point.

Also, if you have mulptiple criteria, you can do something
like the following:

if(me!field1>0, and isnull(me!field2)) then

....

endif

or the following:

if(me!field1>0)then
if(isnull(me!field2))then
...
end if
...
endif

which ever is more appropriate.

I hope this is not confusing. Given more information,
someone in this forum will probably be able to help!

KW
 
Is it possible to make a data field in a FORM mandatory?

Answered in m.p.a.Forms.

Please, if you wish to post to multiple newsgroups, crosspost rather
than multiposting: put all the newsgroups (no more than three) on the
Newsgroups line. Replies will show up in all the newsgroups, and the
volunteers who donate their time here will be less obliged to waste
time reading the same question multiply.
 
Back
Top