The query uses the Expression Service (ES) to try to resolve the parameter
name. If the form is open, the ES succeeds, and so the query uses the value
in the control on the form and does not ask the user for the parameter
value. If the form is not open, the ES is not able to resolve the name, and
so the query does pop up the parameter dialog.
To the query, the OR in the critieria means it has 2 possibilites to
consider. For some cases at least, it must consider both. For example, it is
possible that both forms are open, but neither value matches, but that can
only be determined by examining both.
It would be possible to code around the issue with a function call in your
WHERE clause that attempts to read the value only if:
CurrentProject.AllForms("frmSearchCandidates").IsL oaded
But the better solution would probably be to leave the criteria out of the
query, and apply it later, at whatever point you are working. For example,
you might set the Filter of the particular form, or use the WhereCondition
of OpenReport, or build the entire SQL string in code and apply it to the
SQL property of the QueryDef, the RecordSource of the form or Report, or
OpenRecordset() in code.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"jim Bob" <fr****@gmail.com> wrote in message
news:Py*****************@news.uswest.net...
Hi, I have a query with the criteria of
([forms]![frm_SearchCandidates].[qmyList].[value]) Or
[forms]![frm_CustomQuery].[lstResults].[value]
When I provide the value from qmylist, a second pop up appears waiting
for the value from lstResults. If I enter nothing and click ok, it works
fine. (Vice versa)
Is there a way to suppress the popup if only 1 of the value is supplied?
There by working truly as an OR?