473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Make it compulsory to fill in field in form

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
3 11447
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Song Zhang | last post by:
I need to write asp/script/html code to fill the following function. 1. When a page appA.mycom.com/aa.html (aa.html code shown below) is visited from my site, a user can click the button "Launch",...
4
by: mitch-co2 | last post by:
What I am trying to do is when someone clicks on the YES radio button I want the text field called MYTEXT to equal the text field named DATE. The below code works as long as I do NOT UN-COMMENT...
1
by: ogilby1 | last post by:
Using an immediate if to fill a field on a form based on the value of another field. During data entry on the form this methodology works well. When looking at the results in the datasheet view or...
42
by: WindAndWaves | last post by:
Dear All Can you tell me why you use a class module??? Thank you Nicolaas ---
1
by: marko | last post by:
Here is my problem. How can i make a field in a form change to a value 1 every morning when I turn access on, when the date changes? And how can i make a button on a form which would open another...
6
by: MROPARTNER | last post by:
I have a field in a form called "Date" I am looking to fill this text field with the current date. Is there a way to do this with ASP or an easier way? Thanks Bill
0
by: tshad | last post by:
MSN has a toolbar that has a Form Fill function that will try to fill form fields on forms when they come up. The problem is that it causes problems with some forms and functions. I found this...
0
DressageRider
by: DressageRider | last post by:
I need your help. Desperately. Someone has to be able to fix the utter balls up I've made after dinking around in Flash for the last four days. I have no prior knowledge of anything other than...
8
by: mjvm | last post by:
Hi, I have had a similar question answered but don't understand code sufficiently to adapt it myself. Can someone please help and write the code I need? I have a date field called Received, and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.