Ok I will try to simplify this as mush as possible.
I have a table:
I would like to query this table based on values in fields Region, ReportMonth, and Report Year.
This will be use to generate a report with data from multiple tables. (this is just one example)
So I have a form that has three combo box's and the user can select either all for each field or narrow down by it respective data type.
This form then passes the selected values to public strings to be used in the Where filter on my query.
I have used this function populate the query filter on demand.
Then I put that function as the where filter.
For some reason my query value ends up being blank when I know that I am selecting data that is valid. Let me know what I can do to expand upon my question. Thanks!
I have a table:
Code:
[B]tblTotalHosts[/B] [I][U]Field DataType[/U][/I] ID AutoNumber TotalHosts Number Region Text ReportMonth Text Report Year Number
This will be use to generate a report with data from multiple tables. (this is just one example)
So I have a form that has three combo box's and the user can select either all for each field or narrow down by it respective data type.
This form then passes the selected values to public strings to be used in the Where filter on my query.
Code:
strRegion = Me.cbxRegion.Value
strMonth = Me.cbxMonth.Value
strYear = Me.cbxYear.Value
If strRegion = "All Regions" Then
strRegion = "*"
End If
If strMonth = "All Months" Then
strMonth = "*"
End If
If strYear = "All Years" Then
strYear = "*"
End If
strExportRegion = strRegion
strExportMonth = strMonth
strExportYear = strYear
DoCmd.Close
Code:
Function getStrRegion()
getStrRegion = strExportRegion
End Function
Function getStrMonth()
getStrMonth = strExportMonth
End Function
Function getStrYear()
If Not (strExportYear = "*") Then
getStrYear = CDbl(strExportYear)
End If
End Function
Code:
SELECT Sum(tblTotalHosts.TotalHosts) AS SumOfTotalHosts FROM tblTotalHosts WHERE (((tblTotalHosts.Region) Like getStrRegion()) AND ((tblTotalHosts.ReportMonth) Like getStrMonth()) AND ((tblTotalHosts.ReportYear) Like getStrYear()));
Comment