T
Tina Hudson
Good afternoon,
I have a report menu that gives user the option of previewing several
reports. User clicks on a cmdbutton to open a specific report, and a
parameter form opens, prompting user to select in a cbo box, for example, a
unit name, and press OK, or Cancel.
After unit name is selected, and user presses cmdbutton "OK", the report
opens with info for that unit. No problems here.
PROBLEM: However, if a user changes mind and wants to back out, and clicks
on "cancel", the default Access parameter box opens asking for the Unit name
after "cancel" button is pressed.
Question: how can I make the access parameter box from appearing when the
user clicks cancel?
Here's the code:
cmdbutton on the frmReportMenu to open report:
Dim stDocName As String
stDocName = "rptMonthlyUnitReport"
DoCmd.OpenReport stDocName, acPreview
OnOpen event for report:
Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "frmParamUnit", , , , , acDialog
DoCmd.Maximize
End Sub
The query behind rptMonthlyUnitReport" has the parameter
"=[forms]![frmParamUnit]![cboUnitName]" in the field "UnitName"
The code behind the "cancel" cmdbutton on the parameter form is:
Private Sub cmdCancel_Click()
On Error GoTo Err_cmdCancel_Click
DoCmd.Close
Exit_cmdCancel_Click:
Exit Sub
Err_cmdCancel_Click:
MsgBox Err.Description
Resume Exit_cmdCancel_Click
End Sub
I have a report menu that gives user the option of previewing several
reports. User clicks on a cmdbutton to open a specific report, and a
parameter form opens, prompting user to select in a cbo box, for example, a
unit name, and press OK, or Cancel.
After unit name is selected, and user presses cmdbutton "OK", the report
opens with info for that unit. No problems here.
PROBLEM: However, if a user changes mind and wants to back out, and clicks
on "cancel", the default Access parameter box opens asking for the Unit name
after "cancel" button is pressed.
Question: how can I make the access parameter box from appearing when the
user clicks cancel?
Here's the code:
cmdbutton on the frmReportMenu to open report:
Dim stDocName As String
stDocName = "rptMonthlyUnitReport"
DoCmd.OpenReport stDocName, acPreview
OnOpen event for report:
Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "frmParamUnit", , , , , acDialog
DoCmd.Maximize
End Sub
The query behind rptMonthlyUnitReport" has the parameter
"=[forms]![frmParamUnit]![cboUnitName]" in the field "UnitName"
The code behind the "cancel" cmdbutton on the parameter form is:
Private Sub cmdCancel_Click()
On Error GoTo Err_cmdCancel_Click
DoCmd.Close
Exit_cmdCancel_Click:
Exit Sub
Err_cmdCancel_Click:
MsgBox Err.Description
Resume Exit_cmdCancel_Click
End Sub