Form Window exit checking

ramhanuman

Registered User.
Local time
Yesterday, 19:05
Joined
May 1, 2012
Messages
13
For simplicity's sake let's say I have one text box with an exit button on my form window. Currently, my problem is that if the user opens and then exits the window without entering in anything into the text box, the program saves a blank entry into the database. What I want is for the database to save entries only if the user entered in something and do nothing is the user leaves it blank. So I'm guessing I have to do something for the On Click event for the exit button but am not sure how to go about coding this in VB. Can anyone point me in the right direction? Thank you
 
If your form is creating a new record when it is opened, it is in data entry mode. Change that property to false on the form.
 
So to clarify, I also have a combo box in the form that has a default value when you open the form. So I think that's what is dirtying the form. But how can I make it so that it has to check a specific text box and see if that is null or not before entering into the database
 
The form is an information form, where a user fills out all the information about him/her. There are two combo boxes, state and country. And in the Form_Load class I have:
If IsNull(Country) Then
Me.Country = Me.Country.ItemData(217)
Call Country_AfterUpdate
End If

Private Sub Country_AfterUpdate()
Me.States = Null
Me.States.Requery
Me.States = Me.States.ItemData(0)
End Sub

This displays US as the default selection and the other combo box is dependent on the country so since US is selected, the states combo box displays the 50 states. I think this is what is dirtying the form, what do you think?
 
I don't actually have any window asking the user to save or anything. There is just a save and close button. What I want is, when the user clicks save and close, I want it to check the first name field, see if that is dirty, and if it is then save, if not then don't save. I think I have to add something like

If IsNull([First Name]) Then

In the Form_AfterUpdate class. If so, what should I say to prevent it from inserting?
 

Users who are viewing this thread

Back
Top Bottom