I have a list box (ReportList) with 5 options
Y1 Report
Y10 Report
Y15 Report
Y20 Report
Y25 Report
I also have a button that when triggered opens any of the selected reports along with a where condition:
The reports have different where conditions. For example Y10 Report will have a page condition but not a category condition.
I would like to have a If loop that determines if Y1 selected then the where condition for Y1 is inputted into the DoCmd.
-------------------------
I've come up with the following, any feedback would be appreciated:
If Me!ReportList = Y1 Report then
Y1 = "[Setting] like '*" & Me.cboSetting & "*' and [Category] like '*" & Me.cboCategory & "*'"
Else 0
If Me!ReportList = Y10 Report then
Y10 = "[Setting] like '*" & Me.cboSetting & "*' and [Category] like '*" & Me.cboCategory & "*'"
Else 0
If Me!ReportList = Y15 Report then
y15 = "[Author] like '*" & Me.cboAuthor & "*' and [Category] like '*" & Me.cboCategory & "*'"
Else 0
If Me!ReportList = Y20 Report then
y20 = "[Volume] like '*" & Me.cboVolume & "*' and [Category] like '*" & Me.cboCategory & "*'"
Else 0
If Me!ReportList = Y25 Report then
y25 = "[Country] like '*" & Me.cboCountry & "*' and [Category] like '*" & Me.cboCategory & "*'"
Else 0
strCriteria = >0
DoCmd.Open Report Me!ReportList, 2, WhereCondition:=strCriteria, WindowMode:=acWindowNormal
Y1 Report
Y10 Report
Y15 Report
Y20 Report
Y25 Report
I also have a button that when triggered opens any of the selected reports along with a where condition:
DoCmd.Open Report Me!ReportList, 2, WhereCondition:="[Page] like '*" & Me.cboPageNumber & "*' and [Category] like '*" & Me.cboCategory & "*'", WindowMode:=acWindowNormal
The reports have different where conditions. For example Y10 Report will have a page condition but not a category condition.
I would like to have a If loop that determines if Y1 selected then the where condition for Y1 is inputted into the DoCmd.
-------------------------
I've come up with the following, any feedback would be appreciated:
Dim y1 as String
Dim y10 as String
Dim y15 as String
Dim y20 as String
Dim y25 as String
Dim strCriteria as String
Dim y10 as String
Dim y15 as String
Dim y20 as String
Dim y25 as String
Dim strCriteria as String
If Me!ReportList = Y1 Report then
Y1 = "[Setting] like '*" & Me.cboSetting & "*' and [Category] like '*" & Me.cboCategory & "*'"
Else 0
If Me!ReportList = Y10 Report then
Y10 = "[Setting] like '*" & Me.cboSetting & "*' and [Category] like '*" & Me.cboCategory & "*'"
Else 0
If Me!ReportList = Y15 Report then
y15 = "[Author] like '*" & Me.cboAuthor & "*' and [Category] like '*" & Me.cboCategory & "*'"
Else 0
If Me!ReportList = Y20 Report then
y20 = "[Volume] like '*" & Me.cboVolume & "*' and [Category] like '*" & Me.cboCategory & "*'"
Else 0
If Me!ReportList = Y25 Report then
y25 = "[Country] like '*" & Me.cboCountry & "*' and [Category] like '*" & Me.cboCategory & "*'"
Else 0
strCriteria = >0
DoCmd.Open Report Me!ReportList, 2, WhereCondition:=strCriteria, WindowMode:=acWindowNormal