2 Forms - Optional criteria, is it possible ?

  • Thread starter Thread starter randria
  • Start date Start date
R

randria

Hi,
Is it possible to have [Forms]![frm1]![ctr1] or [Forms]![frm2]![ctr1] in the
criteria of a field query ?

[ctr1] is a number.

thanks.
 
No: not unless *both* forms are open.

The Expression Service will attempt to result the Forms... expression, and
if it doesn't resolve (because the form is not open), you will get the
parameter dialog. I presume that's what you are trying to avoid.

A better solution might be to omit the critieria from the query altogether.
You can then build the filter string as you wish for any form or report.

There's a example of doing that here:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html
The downloadable example illustrates how to build the filter string for
different field types, combinations, and ranges -- without parameters in the
query.
 
Many thanks for your immediate reply. Yes I was trying to avoid the parameter
dialog. thank you for the links.
best regards.

Allen Browne said:
No: not unless *both* forms are open.

The Expression Service will attempt to result the Forms... expression, and
if it doesn't resolve (because the form is not open), you will get the
parameter dialog. I presume that's what you are trying to avoid.

A better solution might be to omit the critieria from the query altogether.
You can then build the filter string as you wish for any form or report.

There's a example of doing that here:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html
The downloadable example illustrates how to build the filter string for
different field types, combinations, and ranges -- without parameters in the
query.

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

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

randria said:
Hi,
Is it possible to have [Forms]![frm1]![ctr1] or [Forms]![frm2]![ctr1] in
the
criteria of a field query ?

[ctr1] is a number.

thanks.
 
Another alternative:

Have a separate "Hidden Form" that is always open.

Have each of the two forms move the criteria to the field in the
hidden form

write the query criteria to always use the hidden form criteria.

Advantage:
any query can use those fields as the criteria is necessary.

disadvantage:
will not work for SQL tables since the form is not addressable
however Allen's solution would then need to be used.

Ron
 
Back
Top