By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,987 Members | 1,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,987 IT Pros & Developers. It's quick & easy.

Make it compulsory to fill in field in form

P: n/a
Hi,

How can I make it compulsory for data to be entered into a field in a form.
Eg it won't allow the user to close the form without filling in a particular
field. An error message appears saying "you must enter data into ....field
before closing form". The user would not necessarily tab or enter this
field so an after update etc would not work.

Thanks, Jain.
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Simplest and safest way is to open your table in design view, and set the
Required property for this field to Yes.

You could also use the BeforeUpdate event of the form (not the control) to
check if the text box IsNull().

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Jain" <en*****@equilore.com> wrote in message
news:d7**********@news-02.connect.com.au...
How can I make it compulsory for data to be entered into a field in a
form. Eg it won't allow the user to close the form without filling in a
particular field. An error message appears saying "you must enter data
into ....field before closing form". The user would not necessarily tab
or enter this field so an after update etc would not work.

Nov 13 '05 #2

P: n/a
Thanks for the info Allen. Unfortunately I'm using a query as the basis
for my form so selecting Required Property in the table doesn't seem to
work.

I like the idea of adding code to Before Update Event of the form. I'm
just started to explore VBA. Could you, or anyone else suggest some
code to bring up an error message if the field is left empty (null) when
the user tries to close the form.

Any help is hugely appreciated. Thanks, Jain.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #3

P: n/a
Jain Brand wrote:
Thanks for the info Allen. Unfortunately I'm using a query as the
basis for my form so selecting Required Property in the table doesn't
seem to work.

I like the idea of adding code to Before Update Event of the form.
I'm just started to explore VBA. Could you, or anyone else suggest
some code to bring up an error message if the field is left empty
(null) when the user tries to close the form.

Any help is hugely appreciated. Thanks, Jain.

*** Sent via Developersdex http://www.developersdex.com ***


If IsNull(FieldName) Then
MsgBox "Must provide value for FieldName"
Cancel = True
End If

BTW, the Required property on a field in a table does carry through to queries
based on that table (would be pretty useless otherwise).

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.