You didn't provide the combo box names or the code you tried, but this should work:
Code:
Public Sub YourButtonName()
'AllDepartment All Years
If IsNull(cboDept) And IsNull(cboFiscalYear) Then
DoCmd.OpenReport "AllDepartment All Years"
End If
'Selected Year All Departments
If IsNull(cboDept) And Not IsNull(cboFiscalYear) Then
DoCmd.OpenReport "Selected Year All Departments"
End If
'Selected Department All Years
If Not IsNull(cboDept) And IsNull(cboFiscalYear) Then
DoCmd.OpenReport "Selected Department All Years"
End If
'Selected Department Selected Year
If Not IsNull(cboDept) And Not IsNull(cboFiscalYear) Then
DoCmd.OpenReport "Selected DepartmentSelected Year"
End If
End Sub
Check/change the names in BLUE.
If you want to preview the report before printing, add
, acViewPreview
to the end of the Docmd lines.
example:
DoCmd.OpenReport "AllDepartment All Years", acViewPreview