Closing a form after the OK is clicked on the informational message

  • Thread starter Thread starter Joyce
  • Start date Start date
J

Joyce

I have a form in my database that after all the data is
entered, a message box displays providing the numberic
case ID assigned through VBA. On the informaitonal
message box, I want the message box and form to close when
the OK button is clicked on the informational message
box. Currently just the message box closes when OK is
clicked. Here is my code, any help you can provide is
appriciated, thank you.



If Me.Dirty = False Then
MsgBox "Thank you for your request." & vbCrLf & _
IIf(IsNull(Me.CaseID.Value), "", "Any future
correspondance about this request please refer to " & _
vbCrLf & "Case Number " & Me.CaseID.Value & _
"."), vbInformation + vbOKOnly, "Confirmation
Message"

'Else
'MsgBox "The record could not be saved. Please
verify that all required information is provided."
'End If

Exit_cmdSave_Click:
Exit Sub

Err_cmdSave_Click:
MsgBox Err.Description
Resume Exit_cmdSave_Click


End Sub
 
Add..

DoCmd.Close

After the MsgBox line, before your Else statement.

You could also be more specific, using the form name:
DoCmd.Close acForm, "frmFormName"

This can be useful if you are on one form and want to
close another that is open.
 
Back
Top