Required Fields for New Form/Record

G

Grasavong

I created a form where all fields are required to have data in it. I used the
BeforeUpdate event procedure to tell the user if the field has not been
entered. The code works but only if the user goes back and updates the field.

I need a code where it can be run on the initial entry of a new form. If the
user puts their cursor in the text box and tabs or clicks into another text
box without entering in the first text box, I want a msgbox to tell them or
at least tell them when they attempt to the save the record.

I've used the validation rule, Onload, Onclick...BeforeUpdate is the only
thing that works in the way I'd like it to.

Is this possible?
-Thanks
 
A

Allen Browne

Use the BeforeUpdate event of the *form* (not of the controls.)

Alternatively, open the table in design view (the one this form gets its
records from), and set the Required property to yes for each field.
 
G

Grasavong

Thank you Allen,
I did what you suggested and it works great for new records. If anyone
starts a new record and tries to save, a message will come up to tell the
user if any empty fields are not completed.

However, the rule doesn't work when it comes to existing records. If someone
needs to update an existing record and leaves a field blank, I want a message
warning the user that they need to complete this field before they are able
to update the record. I figured that since the required property is turned to
'yes' it would tell the user to complete the field?

Thank you,
Gwen
 
A

Allen Browne

Right: when you make the change in Table Design, it asks if you want to test
existing data.

Form_BeforeUpdate should work for this case.
 

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