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
 
Back
Top