Don't Pass Go - Please Help

siskoray

New member
Local time
Today, 08:50
Joined
May 5, 2001
Messages
7
I'm wondering if someone can assist me.

When someone neglects to enter information into a field, I would like my form to message that person that they need to enter information into that field and bring the person back to that field until information has been entered.

I know that I can use conditions in properties, but that requires the user to have entered something first, then delete it and try to tab away.

I VBA I have used the following:

if isnull(me.fieldname) then
msgbox "You must enter a value for this field"
docmd.gotocontrol "fieldname"
else
endif

the result is the msgbox appears, but the user is brought to the next field.

Thank you for any help you may give.
 
Try using this:

if isnull(me.fieldname) then

msgbox "You must enter a value for this field" ,,"Error"
me.fieldname.setfocus

endif

Hope this helps.

Rakier
 
Thank you. Found another path

Thanks very much for the post :)

Actually I gave that a try earlier and what happens is that the tab or click occurs immediately following the msgbox.

What I discovered, however, was cancel=true to my delight.

by using the msgbox then in the next line below

cancel = true

the user is unable to tab or click or do anything else until the condition of not null is met. Worked absolutely great!

Thanks again for the response.
 
If you put your code in the BeforeUpdate event of the field in question rather than the BeforeUpdate event of the form, your code will only be executed if the user actually places the cursor into the field that you are editing. If for some reason he uses the mouse to completely avoid the field, your code would never be executed and therefor, invalid data could be saved to the table.

This type of processing is most effective if the code is placed in the BeforeUpdate event of the form. There is absolutely no way short of a hard power off, for the user to avoid the BeforeUpdate event of a dirty form.
 
Hmmmm Never condidered that. Thank you!

It never dawned on me to try that. I've always used a series of code in the "Afterupdate" of the form <with a Command Button with the label "Process"> to check of isnull values before the values were to be saved, but never thought of using Beforeupdate.

This opens up a world of possibilities. Thanks for the reply. :)
 

Users who are viewing this thread

Back
Top Bottom