Close form

T

Tony Williams

If the user clicks No in this message I want the form to close, but I get a
message that says This action can't be carried out while processing a form
or report.
Here is my code
Private Sub txtMontha_LostFocus()
On Error GoTo Err_txtMontha_LostFocus
Dim MsgStr As String
Dim TitleStr As String
MsgStr = "You can not enter a record without " _
& "completing the Qtr End Date" & vbCrLf & vbCrLf _
& "Do You Wish To Go Back " _
& "And Enter The Qtr End Date?"
TitleStr = "Qtr End Date Must Be Entered"
If IsNull(Me!txtMontha) Or Me!txtMontha = "" Then
If MsgBox(MsgStr, vbYesNo, TitleStr) = vbYes Then
Cancel = True
Me.txtMonthlabela.SetFocus
Me.txtMontha.SetFocus

Else
Me.Undo
DoCmd.Close acForm, Me.Name
End If
End If
Exit_txtMontha_LostFocus:
Exit Sub

Err_txtMontha_LostFocus:
MsgBox Err.Description
Resume Exit_txtMontha_LostFocus
End Sub

Can anyone help?
Thanks
Tony
 

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