If date field is 1 or not entered then prompt to choose before clo

G

Guest

I have a form with subform.
When the user clicks to close form, check to see if the date field is left
as a 1 or null
If it is 1 or null, prompt to make sure they want to exit without choosing
date.

My below code is not working. Any suggestions?

Private Sub Form_Close()
On Error GoTo Err_FormClose
If IsNull(Me.ReportDtID) Or Me.ReportDtID = 1 Or Me.ReportDtID = "Enter
Date" Then
Me.AllowEdits = True
Forms!f2CustImpactsEdit.Form!f2CustImpactsEditDetails.Form.AllowEdits =
True
Me.AllowDeletions = True

Forms!f2CustImpactsEdit.Form!f2CustImpactsEditDetails.Form.AllowDeletions =
True

Msg = "Are you sure you want to close without choosing a date? This will
delete the record."
Ans = MsgBox(Msg, vbYesNo)

If Ans = vbNo Then
MsgBox "The Customer Impact has NOT been deleted. Choose date and close form"
Exit Sub
Else
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

End If
End If
exit_Form_Close:
Exit Sub

Err_Form_Close:
MsgBox Err.Description
Resume exit_Form_Close
deb
 
G

Guest

I figured it out...
Private Sub Form_Unload(Cancel As Integer)

If IsNull(Me.ReportDtID) Or Me.ReportDtID = 1 Or Me.ReportDtID = "Enter
Date" Then
Me.AllowEdits = True
Forms!f2CustImpactsEdit.Form!f2CustImpactsEditDetails.Form.AllowEdits = True
Me.AllowDeletions = True
Forms!f2CustImpactsEdit.Form!f2CustImpactsEditDetails.Form.AllowDeletions =
True

Msg = "You have not entered a report date? If you close now, this Customer
Impact will NOT be saved. Do you want to close?"
Ans = MsgBox(Msg, vbYesNo)

If Ans = vbNo Then
MsgBox "Please, choose Report Date."
Cancel = True

Else
Me.Undo
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
End If
Exit Sub

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top