Hi, I have an option group to select different reports, each report is based off a query that asks for criteria for that report. I have no problem opening any the querys through the group regardless of the data involved. The problem arises when you go to open a report and click the cancel button on the criteria question. I get a "Run Time Error 2501", "The Open Report Action was canceled". The error occurs only on the reoprt in the elseif statement. The grpreport = 6 opens other forms that have the criteria on the form, because there are 14 different criterias the query looks at. The grprrport = 6 also uses a macro for that specific report. The code I used is as to open the reports is as follows:
The program stops at the DoCmd.openrepor t line. I won't added the rest of the option buttons for reports untill I get past this problem. Can anyone help me capture the error?
Code:
Private Sub cmdreport_Click() On Error GoTo Err_cmbreport_Click Dim stDocName As String Dim stLinkCriteria As String If Me.grpreports = 6 Then DoCmd.Close stDocName = "design type" DoCmd.OpenForm stDocName, , , stLinkCriteria ElseIf Me.grpreports = 1 Then DoCmd.Close DoCmd.OpenReport "raw data for a bar", acViewReport Exit_cmbreport_Click: Exit Sub If Err.Number = 2501 Then Resume Next Else Err_cmbreport_Click: MsgBox Err.Description Resume Exit_cmbreport_Click End If End If End Sub
Comment