Filter problem in report

A

anil

Hi all
I am trying to filter the report based on the combo boxes in form,
using the following code

Me.Filter = "LocationName = " & LocationName & " AND " & "ParameterName
= " & _ ParameterName
DoCmd.OpenReport "rptResults", acViewPreview, , Me.Filter

but when I press the button and report opens it asks for the 'Enter
Parameter' both both fields.
Interesting thing is that it asks for 'VALUE' of location name e.g
"Ararat" and parameterName e.g "pH" instead of 'FIELDS' -LocationName
and ParameterName

when i open form next time with different LocationName and
ParameterName in combo box it again asks for that "VALUE" of
LcoationName and parameterName.

I have set filter = No in properties.Report is based on query and same
query I have used in form recordsource.

Since its asks for "Ararat" and not LocationName so I can't add it in
parameters.
Please help me where I am making the mistake

thanks
anil
 
G

Guest

Anil:

If you are using parameters you don't need to set the Filter property of the
report at all. Just reference the two combo boxes as parameters in the
report's RecordSource query. Under the LocationName column in query design
view enter in the criteria row:

Forms!YourFormName!LocationName

and in the criteria row under the ParameterName column enter:

Forms!YourFormName!ParameterName

Then just open the report with:

DoCmd.OpenReport "rptResults", _
View:=acViewPreview

The other way would be not to have any parameters referencing the form in
the query and filter the report like so:

Dim strCriteria As String

strCriteria = "LocationName = """ & LocationName & _
""" And ParameterName = """ & ParameterName & """"

DoCmd.OpenReport "rptResults", _
View:=acViewPreview, _
WhereCondition:=strCriteria

The above assumes both fields are of text data type, so wraps the values in
quotes characters.

Ken Sheridan
Stafford, England
 
A

anil

Thanks Guys
There was the problem of text field.Actually I changed from Id to name
and did not add double quotation .
Thanks again
anil
 
A

anil

Thanks Guys
There was the problem of text field.Actually I changed from Id to name
and did not add double quotation .
Thanks again
anil
 

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