If fields null dont let advance when clicking buttons until user fills fields.

rodvaN

Registered User.
Local time
Today, 11:35
Joined
May 20, 2009
Messages
92
As the topic says.. I dont have configured those fields on the table to be required because other options in database will have conflicts.
But I would like to make a VBA to check if one of those 5 fields, or the 5, or 4 fields are Null when user clicks on "button1" and then display a MSGBOX advicing to fill the fields.
I attached a screenshot for a better understanding.
Thanks again.
 

Attachments

  • EXAMPLE2.jpg
    EXAMPLE2.jpg
    97.6 KB · Views: 149
I would use the before update event of the form:

http://www.baldyweb.com/BeforeUpdate.htm

You may also want code behind those buttons, depending on what they do. If it turns out you need the code in more than one place, create a function that does the testing, and call it from those places.
 
Im trying this
On Form_Load
Me.Cliente.SetFocus


and on the Cliente field..
Cliente_LostFocus()
If Me.Cliente = Null then
Msgbox "you gotta type something in Cliente field"
Me.Cliente.Setfocus
Else
Me.Order.Setfocus
End if

This is throwing me an runcommand error..
What Am I doing wrong?
Thanks in advance.
 
For starters, nothing is ever = Null. Try the test from my link. Second, trying to control focus from control to control is more trouble than it's worth, in my opinion. Again, I would let the user wander around if they want, and use the form's before update event to ensure valid data. If you insist, you'll find you have to set focus elsewhere and then where you really want it when trying to set it from the lost focus event.
 

Users who are viewing this thread

Back
Top Bottom