I have a form with text fields so a user can enter information. I am trying to make this form more robust so if the user has some information entered on the form and he clicks the close button in the top right corner, I want to ask the user if he really wants to close the form. I have the following code in the Form_Close() section of the code:
Private Sub Form_Close()
If (txtName.text = "" or IsNull(txtName.text) Then
formchange=true
End if
If (formchange=true) Then
Dim Response as integer
Response = MsgBox("Do you really want to close?", vbYesNoCancel)
...
End if
End Sub
When I test this out, I get an error saying one of my fields can't be null because the required property is set to true. Access tells me that I can't save this record at this time, but do I want to close the database object anyway.
After all those error messages, THEN my code will run. How can I bypass all of that? Any ideas? Thanks!!
Private Sub Form_Close()
If (txtName.text = "" or IsNull(txtName.text) Then
formchange=true
End if
If (formchange=true) Then
Dim Response as integer
Response = MsgBox("Do you really want to close?", vbYesNoCancel)
...
End if
End Sub
When I test this out, I get an error saying one of my fields can't be null because the required property is set to true. Access tells me that I can't save this record at this time, but do I want to close the database object anyway.
After all those error messages, THEN my code will run. How can I bypass all of that? Any ideas? Thanks!!