2 Forms - Optional criteria, is it possible ?

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.
 
A

Allen Browne

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.
 
R

randria

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.
 
R

Ron2006

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
 

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