how to pass a parameter to a query from a form

  • Thread starter Thread starter DevX
  • Start date Start date
D

DevX

Hi to all,

I have a form that show, for example, Table1. I want to press a button and
show a Report that display a query, this query must be filtered by a value
located in the first from.

I tried with [Forms]![Form1]![Field1] in the criterion of the query but it
seems that when I open the report (and run the query) this value is not
visible and Access show me the input box requiring the parameter to be
inputted by hand.

Any idea (I hope that I described correctly the problem, sorry for my
English).

DevX
 
Use the Where Condition argument of the OpenReport method.
strDocName = "NameOfMyReport"
strWhere = "[FieldNameToFilterOn] = '" & [Forms]![Form1]![Field1] & "'"
DoCmd.OpenReport strDocName, , , strWhere
 
Thanks a lot Klatuu. It's working very well now.

DevX

Klatuu said:
Use the Where Condition argument of the OpenReport method.
strDocName = "NameOfMyReport"
strWhere = "[FieldNameToFilterOn] = '" & [Forms]![Form1]![Field1] & "'"
DoCmd.OpenReport strDocName, , , strWhere

DevX said:
Hi to all,

I have a form that show, for example, Table1. I want to press a button and
show a Report that display a query, this query must be filtered by a value
located in the first from.

I tried with [Forms]![Form1]![Field1] in the criterion of the query but it
seems that when I open the report (and run the query) this value is not
visible and Access show me the input box requiring the parameter to be
inputted by hand.

Any idea (I hope that I described correctly the problem, sorry for my
English).

DevX
 

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

Back
Top