open report from form with filter

Caitlin11

Registered User.
Local time
Today, 22:11
Joined
Jan 29, 2003
Messages
19
Hi - I know there are lots of posts about this but I can't get anything to work. I know I must be missing something. Here's the scenario:

I have a form that has button to call a report that is based on a table. The table that the report is based on has a field called "grade". When this button is pressed - I want to open the report and show records where grade = '1'. Here's the code I have in the ONCLICK prop of the button:

Dim stDocName As String

stDocName = "rpt_grade1-4_report_card"
strCondition = "reports!rpt_grade1-4_report_card!grade = '1'"
DoCmd.OpenReport stDocName, acPreview, , strCondition


I also tried changing strCondition to:
strCondition = "[Grade] = '1'"

But that didn't work either. I don't get an error. It just brings up the report with ALL records instead of just the ones where grade = '1'.

Any ideas???

Thanks in advance.

Caitlin
 
Caitlin,

Code:
Dim stDocName As String

stDocName = "rpt_grade1-4_report_card"
strCondition = "[grade] = '1'"
DoCmd.OpenReport stDocName, acPreview, , strCondition

Or, If grade is a numeric field ...

strCondition = "[grade] = 1"

Wayne
 
Hi Wayne - thanks for the post. I tried changing the code as you suggested (grade is a text field) but it still pulls ALL records.

Any other ideas?
 
Did you set the 'Filters on' property to yes in the report's propertys?

ken
 

Users who are viewing this thread

Back
Top Bottom