D
Dee
Good Morning:
Heres the scenario. I have a standard report R based on a
standard query Q. Q fetches all records from the tables
its based on. At run-time I create a new report S (from
std report R) whose record-source is a new query T whose
criteria (sql) I define at run-time based on the user's
selection. The select clause of T is based on std query Q,
only its where clause has conditions depending on user's
input. (whereas Q has no where clause since it is generic)
So,
report R -> new report S (run-time)
query Q -> new query T (run-time) with where clause
At run-time the report S gives me a #error each time. If I
run the new query as-is, interactively, I get no records.
However, if I save this query, without any changes (dummy
save), interactively, then it fetches the data. And if I
run the report S also interactively after the
dummy_query_save, it gets data correctly.
Whats happening here?
The run-time code uses DAO to create the dynamic query T
and docmd to create the report S. I cannot use query
parameters because not all parameters are required. So I
have to resort to defining a dynamic where clause at run-
time.
Heres the scenario. I have a standard report R based on a
standard query Q. Q fetches all records from the tables
its based on. At run-time I create a new report S (from
std report R) whose record-source is a new query T whose
criteria (sql) I define at run-time based on the user's
selection. The select clause of T is based on std query Q,
only its where clause has conditions depending on user's
input. (whereas Q has no where clause since it is generic)
So,
report R -> new report S (run-time)
query Q -> new query T (run-time) with where clause
At run-time the report S gives me a #error each time. If I
run the new query as-is, interactively, I get no records.
However, if I save this query, without any changes (dummy
save), interactively, then it fetches the data. And if I
run the report S also interactively after the
dummy_query_save, it gets data correctly.
Whats happening here?
The run-time code uses DAO to create the dynamic query T
and docmd to create the report S. I cannot use query
parameters because not all parameters are required. So I
have to resort to defining a dynamic where clause at run-
time.