Hank.School
Registered User.
- Local time
- Today, 15:34
- Joined
- Oct 14, 2016
- Messages
- 39
Hi guys,
I have a report based off of a query which pulls data from multiple tables. I also have a search form to locate a specific record. The search form works fine and on the form I have a button to open the report with:
DoCmd.OpenReport strReportname, acViewPreview, , strCriteria
No matter what I set the Criteria string to, the report always seems to open to the same record (first one in the table). It does display only one record but it is not the right record. I even tried setting it manually to a specific record to test it and it still opens to the first record.
The Criteria right now is set with:
strCriteria = "[Loc_Code] =" & [SearchResults].[Column](3)
Loc_Code is the name of the field from the query that I want to filter on (the text box on the report where that field lands is named Text5. I tried using that too).
SearchResults is the query for the search form and column 3 of a listbox holds the Loc_Code parameter. It displays properly in the search form so I know the reference to that value is correct.
When the report comes up, the fields are filled in correctly (though with the wrong record) including the Loc_Code field.
For some reason, the criteria is not filtering properly. When I look for examples on the web they all seem to follow this format. Does anyone know what I am doing wrong here? :banghead:
Thanks
Hank
I have a report based off of a query which pulls data from multiple tables. I also have a search form to locate a specific record. The search form works fine and on the form I have a button to open the report with:
DoCmd.OpenReport strReportname, acViewPreview, , strCriteria
No matter what I set the Criteria string to, the report always seems to open to the same record (first one in the table). It does display only one record but it is not the right record. I even tried setting it manually to a specific record to test it and it still opens to the first record.
The Criteria right now is set with:
strCriteria = "[Loc_Code] =" & [SearchResults].[Column](3)
Loc_Code is the name of the field from the query that I want to filter on (the text box on the report where that field lands is named Text5. I tried using that too).
SearchResults is the query for the search form and column 3 of a listbox holds the Loc_Code parameter. It displays properly in the search form so I know the reference to that value is correct.
When the report comes up, the fields are filled in correctly (though with the wrong record) including the Loc_Code field.
For some reason, the criteria is not filtering properly. When I look for examples on the web they all seem to follow this format. Does anyone know what I am doing wrong here? :banghead:
Thanks
Hank