Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter not working on Report

Status
Not open for further replies.

NWTrust

Technical User
Apr 2, 2002
68
0
0
GB
Hi
I need to display selected entries on a form and also a report. The selection is in a variable called gstrTester. The call to the form is: DoCmd.OpenForm FormName:="frmSelected", WhereCondition:=gstrTester. The contents of gstrTester appear in the form's Property Sheet Filter box and the form appears correctly.

The same does not happen with the report. The call DoCmd.OpenReport "rptSelected", WhereCondition:=gstrTester does not fill the report filter box and so the complete table is printed, not just the selected entries.

Can someone please tell me what I'm doing wrong?

NWTrust
 
Is gstrTester just a simple string or a boolean equation? I would think you need to use something like:
Code:
DoCmd.OpenReport "rptSelected", WhereCondition:="[SomeFieldName]=""" & gstrTester & """"

Duane
Hook'D on Access
MS Access MVP
 
gstrTester is a string containing a field name and a name within the field.

 
Sorry, I should have been a bit more specific. gstrTester contains: [field name] = "word(s) to search for
 
It would have been helpfull if you had provided some exact contents of gstrTester.

To help trouble-shoot, add a text box in the Report Header section with a control source of:
Code:
=[Filter]

Duane
Hook'D on Access
MS Access MVP
 
An example of the contents of gstrTester is [Parish] = "Drayton]" to list all entries where the Parish is Drayton. As I stated originally this works perfectly in a form but not a report.

I'm not sure what you mean about adding a text box.
 
In your report design view, select the text box control from the Toolbox and add it to your report header section. Then just set its control source property as suggested.


Duane
Hook'D on Access
MS Access MVP
 
Thanks for your time dhookom. I have been 'fiddling' and somehow have solved the problem (I'm not sure how but I don't feel inclined to find out!). Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top