Check for empty fields

  • Thread starter Thread starter Gee
  • Start date Start date
G

Gee

I have a form for service calls.
My users are not filling out all the required fields.
If I make a field required in the table it does not save the record and I
want to do it another way, anyway.
What I really want is a test for particular fields when the close button I
built is clicked, before it closes I want it to see if the fields "Date",
"Generated", "PO" and "Emails" are null, if they are, a message box pops up
and says to go back and fill in empty fields, click that closed and it goes
back to the incomplete form. When all required fields are filled in it just
closes.
It's in Access 02.

Thank you in advance for any help you can give me.
Gee
 
Those things are normally checked for in the BeforeUpdate event.
For each required field, you need something like:

If NZ(Trim(Me!Field),vbnullstring) = vbnullstring then
Msgbox "Field X is required",,"Missing date"
Me!Field.setfocus
Cancel = True
Exit Sub
End if

I'm assuming those fields are in the table which is bound to your form.
You don't want to rely on the Required attribute in the table definition.
-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
Hello Dorian,
I used that code, it gave me the pop up that said "Field X is required",
but then it went ahead and closed the form...it didn't leave it open and
focus to that empty field.
 
Back
Top