I have a form that has a combo box that allows the user to select which report and a date range that they want for the report. The report was built using a table. (PHV I moved this out of the other thread because it needed a different subject title).
I'm having problems with the where condition on the DoCmd.OpenReport. I capture the combo values of both the report they want and the dates. I'm not sure how to place all values in the where condition. I've tried it different ways - 1 to create a str_Where variable that will capture all values, then use that variable in the DoCmd statement and another to break down all values into separate str_Wheres and bring them all together in the Where condition. Below is my latest attempt to bring the separate values to create one where condition, a date range, and a status. I just don't know how to code it correctly either way. I saw that the values are good, then tried to bring them all into one statement:
If str_Report_Selected = "Listings Sold" Then
str_Report_Title = "Listings Sold"
str_Where1 = "tbl_Listings.Status = '2 - Sold'"
str_Where2 = "tbl_Listings.Start_Date >= Me.combo_Start_Date"
str_Where3 = "tbl_Listings.End_Date <= Me.combo_Start_Date"
End If
When I try to bring the 3 different "Wheres" together the value created looks like this:
'(tbl_Listings.Status = '2 - Sold'tbl_Listings.Start_Date >= Me.combo_Start_Datetbl_Listings.End_Date <= Me.combo_Start_Date)'
All running together. I tried various things like " ", AND, & - But I'm not sure what to do. The good part is it is finding the table fields, I just need to know how the format the Where statement.
str_Where = str_Where1 + ";" str_Where2 + ";" str_Where3
DoCmd.OpenReport str_Report_Name, acViewPreview, , str_Where
Just not sure of the syntax. Thanks!
I'm having problems with the where condition on the DoCmd.OpenReport. I capture the combo values of both the report they want and the dates. I'm not sure how to place all values in the where condition. I've tried it different ways - 1 to create a str_Where variable that will capture all values, then use that variable in the DoCmd statement and another to break down all values into separate str_Wheres and bring them all together in the Where condition. Below is my latest attempt to bring the separate values to create one where condition, a date range, and a status. I just don't know how to code it correctly either way. I saw that the values are good, then tried to bring them all into one statement:
If str_Report_Selected = "Listings Sold" Then
str_Report_Title = "Listings Sold"
str_Where1 = "tbl_Listings.Status = '2 - Sold'"
str_Where2 = "tbl_Listings.Start_Date >= Me.combo_Start_Date"
str_Where3 = "tbl_Listings.End_Date <= Me.combo_Start_Date"
End If
When I try to bring the 3 different "Wheres" together the value created looks like this:
'(tbl_Listings.Status = '2 - Sold'tbl_Listings.Start_Date >= Me.combo_Start_Datetbl_Listings.End_Date <= Me.combo_Start_Date)'
All running together. I tried various things like " ", AND, & - But I'm not sure what to do. The good part is it is finding the table fields, I just need to know how the format the Where statement.
str_Where = str_Where1 + ";" str_Where2 + ";" str_Where3
DoCmd.OpenReport str_Report_Name, acViewPreview, , str_Where
Just not sure of the syntax. Thanks!