Problem with Where Clause in a Report

  • Thread starter Antonio CC via AccessMonster.com
  • Start date
A

Antonio CC via AccessMonster.com

Hi,

I need to print the individual information of one givem project. All the
projects are stored in a table and I have a report that will print all the
projects in a table, unless I filter the data.

I have a control button in a form which will open the report like this:

'---------------------------------------------------------------------
Private Sub PrintProjectInfo_Click()

DoCmd.OpenReport "ProjectDetail", acViewPreview, , "ProjectCode = " & Me.
ProjectCode

End Sub
'---------------------------------------------------------------------

However, the report still shows all records in the table. Note that there
isn't any filter/where in the report query. I've tried Where Clause and
Filter, but nothing...

Anyone?

Thanks

Antonio
 
M

MacDermott

Is ProjectCode perhaps a string?
In that case your WhereCondition should look like this:
"ProjectCode = '" & Me.ProjectCode & "'"
 
A

Antonio CC via AccessMonster.com

Yes, ProjectCode refers to a Text Field.

I'm now using:

StrFilter = "ProjectCode = '" & Me.ProjectCode & "'"

DoCmd.OpenReport "ProjectDetail", acViewPreview, , StrFilter

But it still returns all the records in the Table...

Is ProjectCode perhaps a string?
In that case your WhereCondition should look like this:
"ProjectCode = '" & Me.ProjectCode & "'"
[quoted text clipped - 22 lines]
 
M

MacDermott

I don't see anything obviously wrong in your statement, so I'll ask a couple
of simplistic questions:

If you stop your code with a breakpoint at DoCmd.OpenReport, what is the
value of StrFilter?

Is your report open in DesignView when you execute this code?

Does your data include more than one ProductCode?


Antonio CC via AccessMonster.com said:
Yes, ProjectCode refers to a Text Field.

I'm now using:

StrFilter = "ProjectCode = '" & Me.ProjectCode & "'"

DoCmd.OpenReport "ProjectDetail", acViewPreview, , StrFilter

But it still returns all the records in the Table...

Is ProjectCode perhaps a string?
In that case your WhereCondition should look like this:
"ProjectCode = '" & Me.ProjectCode & "'"
[quoted text clipped - 22 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top