DanG
Registered User.
- Local time
- Today, 03:36
- Joined
- Nov 4, 2004
- Messages
- 477
Hello,
I have always been fine taking existing code and adapting it, but not at writing my own from scratch
I have a report (rpt_MSR_Detail_byAdvisor) that I want to open from a form (called ReportCentral) and on that form I have 2 combo boxes (DistrictPicker & AdvisorPicker). I would like to use the value of either field (not both at the same time like a cascade) to open the report or if left blank open to all records.
Below is the code I have thus far. I tried implementing the "or" on the criteria, but it doesn't work. I understand why, but it does illustrate pretty much what I want to do.
What I think the answer is, is to establish a variable that contains either fields value (or null) and insert the variable into the report criteria., But I not quite sure how to do it.
Any pointer would help a lot!
Thank you
I have always been fine taking existing code and adapting it, but not at writing my own from scratch
I have a report (rpt_MSR_Detail_byAdvisor) that I want to open from a form (called ReportCentral) and on that form I have 2 combo boxes (DistrictPicker & AdvisorPicker). I would like to use the value of either field (not both at the same time like a cascade) to open the report or if left blank open to all records.
Below is the code I have thus far. I tried implementing the "or" on the criteria, but it doesn't work. I understand why, but it does illustrate pretty much what I want to do.
What I think the answer is, is to establish a variable that contains either fields value (or null) and insert the variable into the report criteria., But I not quite sure how to do it.
Code:
Private Sub MSRDetail_Click()
On Error GoTo Err_MSRDetail_Click
Dim stDocName As String
stDocName = ReportPicker.Value
DoCmd.OpenReport stDocName, acPreview, , "IIf([Forms]![frmReportCentral]![DistrictPicker] Is Null,"""",[txtDistNum]=[Forms]![frmReportCentral]![DistrictPicker])or IIf([Forms]![frmReportCentral]![AdvisorPicker] Is Null,"""",[txtEmpNum]=[Forms]![frmReportCentral]![AdvisorPicker])"
Exit_MSRDetail_Click:
Exit Sub
Err_MSRDetail_Click:
MsgBox Err.Description
Resume Exit_MSRDetail_Click
End Sub
Any pointer would help a lot!
Thank you