Retrieve value from parameter in bound query

G

Guest

I have a report bound to a query that has a parameter filter on a date field.
Is there any way to retrieve the value that the user enters into the
parameter dialog box?

I've tried accessing the Parameter object from the QueryDef, but the Value
property is always empty during Report_Open or Report_Activate (the former
occurs before the dialog is presented anyway). I also can't just construct
the query SQL with VBA, as the query references multiple queries all with the
same named parameter (I like how nested parameters don't require multiple
entries by the user if they are all the same name - the value is propagated
throughout the nestings).
 
A

Allen Browne

If hte parameter is named (say) WotDate, in your report you can refer to the
parameter just as if it were a field. For example, you could add a text box
and set its Control Source to:
=[WotDate]

If the query reads a value from a form, e.g.:
[Forms].[Form1].[Text0]
provided the form remains open you can have the report read it directly from
the form. The Control Source would be:
=[Forms].[Form1].[Text0]

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

message
news:D[email protected]...
 
G

Guest

That was easy! I can't believe I never thought of that, given that I've been
using parameters in expressions.

Thanks Allen!

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


Allen Browne said:
If hte parameter is named (say) WotDate, in your report you can refer to the
parameter just as if it were a field. For example, you could add a text box
and set its Control Source to:
=[WotDate]

If the query reads a value from a form, e.g.:
[Forms].[Form1].[Text0]
provided the form remains open you can have the report read it directly from
the form. The Control Source would be:
=[Forms].[Form1].[Text0]

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

message
I have a report bound to a query that has a parameter filter on a date
field.
Is there any way to retrieve the value that the user enters into the
parameter dialog box?

I've tried accessing the Parameter object from the QueryDef, but the Value
property is always empty during Report_Open or Report_Activate (the former
occurs before the dialog is presented anyway). I also can't just
construct
the query SQL with VBA, as the query references multiple queries all with
the
same named parameter (I like how nested parameters don't require multiple
entries by the user if they are all the same name - the value is
propagated
throughout the nestings).

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
 

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