I am trying to add an on error messages to this code:
I am trying to Display the message “The Output file is currently open. Please close and re-try” This should display when the file is open and the user tries to generate the file.
Thanks
Code:
Private Sub Repurchase_Excel_Report_Click()
If IsNull(Me!START_DATE.Value) Then
MsgBox "Please Enter Start Date", vbOKOnly, "Start Date Missing"
Cancel = True
GoTo Err_Repurchase_Excel_Report_Click
End If
If IsNull(Me!END_DATE.Value) Then
MsgBox "Please Enter End Date", vbOKOnly, "End Date Missing"
Cancel = True
GoTo Err_Repurchase_Excel_Report_Click
End If
On Error GoTo Err_Repurchase_Excel_Report_Click
DoCmd.OutputTo acQuery, "Repurchase_Query", "MicrosoftExcel 97-10(*.xls)", "C:\Repurchase Report.xls", True, ""
Err_Repurchase_Excel_Report_Click:
Exit Sub
End Sub