Hi all,
I'm going around in circles after reading loads of posts on this and have sucumbed to begging for your much needed help!
I have a form with many fields. If only part of the form has been completed and a user tries to close or exit the form, I am wanting to apply a warning before closing the form. I have got a "return to home" and a "quit app" button and I am also trying to trap the naughty little 'X' button as well.
I have got the codes, below, which is a mish-mash of wrogness!
Regards,
Paul.
I'm going around in circles after reading loads of posts on this and have sucumbed to begging for your much needed help!
I have a form with many fields. If only part of the form has been completed and a user tries to close or exit the form, I am wanting to apply a warning before closing the form. I have got a "return to home" and a "quit app" button and I am also trying to trap the naughty little 'X' button as well.
I have got the codes, below, which is a mish-mash of wrogness!
Regards,
Paul.
Code:
Private Function CloseTheForm() As Boolean
Dim Ctrl As Control
For Each Ctrl In Me.Controls
If Ctrl.Tag = "DataCheck" Then
If Len(Ctrl & vbNullString) > 0 Then
If MsgBox("This record is incomplete." & vbNewLine & vbNewLine & _
"Do you still wish to exit this form?", vbYesNo, "Incomplete Record") = vbYes Then
Forms("frm_TestOne").OnUnload = ""
Else
Exit For
End If
End If
End If
Next Ctrl
End Function
-----------------------
Private Sub Form_Unload(Cancel As Integer)
Cancel = True
End Sub
-----------------------
Private Sub cmdHome_Click()
CloseTheForm
DoCmd.Close
End Sub
-----------------------
Private Sub cmdExitApp_Click()
CloseTheForm
DoCmd.Quit
End Sub