Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a bound form that I am requiring users to fill in all the fileds and
then prompt them is there are blank fileds. I cannot have the field marked
as "Required" in the table view because some fields are being used on other
forms. I have tried other suggestions by modifying the forms code, but I
can't seem to get it to work. What to do? I am a novice access user.
 
Unfortunately it's not a trivial problem....
You need to set up a 'BeforeUpdate' event for the form.
You need to enter in this event procedure, code to check every control on
your form for blank and if any are found to generate an error message and
cancel the update event.
The code will be something like:

If NZ(Trim(Me!Field1),vbnullstring) = vbnullstring then
msgbox "Field 1 blank",vbokonly,"Error"
Me!Field1.setfocus
cancel = 1
exit sub
end if
If NZ(Trim(Me!Field2),vbnullstring) = vbnullstring then
msgbox "Field 2 blank",vbokonly,"Error"
Me!Field2.setfocus
cancel = 1
exit sub
end if
etc. etc.

-Dorian
 
Is this the only way to perform this operation?
I have about 7 different forms to which I would like this applied to, and it
seems that would be a lengthy task.
Are there others ways to verify that all fileds have been filled in, and if
not display a message (possibly a SAVE button)?.

Thank You
 
I have tried your method with no such luck. I am able to not enter data into
any of the fields and I will receive the "Field1 Blank" message. Then after
I click on "OK" button I receive a run time error 438 "Object doesn't support
this property or method", and it points to the line - Me!Field1.setfocus
line when I debug. I have tested this on both a combo box and text box with
the same results. I have made sure the field names are typed correctly for
Field1. Any suggestions?????
 
Back
Top