VBA Access---Closing a form properly?
VB Code:
Private Sub OptShowAll_GotFocus()
On Error GoTo OptShowAll_Err
DoCmd.Echo False, ""
DoCmd.Hourglass True
cmbxFilter = ""
DoCmd.Close acReport, "MonthlyReconciliations(CndExcel)"
DoCmd.OpenReport "MonthlyReconciliations(CndExcel)", acViewPreview
DoCmd.Maximize
DoCmd.RunCommand acCmdFitToWindow
DoCmd.Close acForm, "ReconciliationsFilter(CndExcel)"
OptShowAll_Exit:
DoCmd.Echo True, ""
DoCmd.Hourglass False
Exit Sub
OptShowAll_Err:
MsgBox Error$
Resume OptShowAll_Exit
End Sub
The line:
DoCmd.Close acForm, "ReconciliationsFilter(CndExcel)"
Error Message:
"This action can't be carried out while processing a form or report event."
I think this is because of the OpenReport method. My report never opens properly. What other way can I open a report?