Problem with Where Clause/Filter in a Report

G

Guest

Hi,

I need to print the individual information of one given 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
 
T

Tom Lake

I need to print the individual information of one given 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...

Is ProjectCode a number? If not, try this:

DoCmd.OpenReport "ProjectDetail", acViewPreview, , "[ProjectCode] = '" &
[ProjectCode] & "'"

Tom Lake
 
G

Guest

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...

Tom Lake said:
I need to print the individual information of one given 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...

Is ProjectCode a number? If not, try this:

DoCmd.OpenReport "ProjectDetail", acViewPreview, , "[ProjectCode] = '" &
[ProjectCode] & "'"

Tom Lake
 

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