change query criteria dynamically with value from a 2nd form

E

ecwhite

Hello,

I have a query with multiple criteria passed from a form named "main". I
want to pass the criteria to the same query from a different form from the
click event of a hyperlink field returned from a different query. How do i
pass / change the current query criteria from its current value to the value
coming from the second form dynamically. My code in the query design looks
like

From Form main (To the same field in the query design)

Nz([Forms]![Main]![txt_fin_nbr],"00000")

When the criteria is not coming from form Main, i want it to be

Nz([Forms]![frm_display_multiple_patient_names]![fin_nbr], "00000")

The reason I want to use the same query is because a big form with 9
Tabcontrols has this query as its record source and i want to keep everything
the same no matter which form supplied the value to the query when the form
opens.

Thanks.
 
A

Allen Browne

The best solution is to omit the criteria from the query, and use a filter
string instead.

You build the filter string in whatever form you need it and that apply it
as the Filter of the form or report.

Here's an example of how to build such a string:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html

You will need some familiarity with VBA code to achieve this, but the code
is designed so you can easily add more and more boxes to filter on if you
need to.
 

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