projection
Programmer
Hi,
I have an interesting problem where I want to create a report using a select statement having a subquery union of several tables (partial query below). The sub union query has a variable (sPeriod) that will be set to the Period ending Date specified on the form before the user clicks view report.
Instead of coding this really long query in VB, how can I use this query as the recordsource and pass the value to the report and have it set the sPeriod variable in the subquery to the value? The where condition on openReport command only works with top level queries, at least that was my assumption as it didn't work when I tried. I cannot have the dateEntered as part of the top level query.
Another issue with coding a really long query in VB and setting it to the recordsource before opening the report is that there is a length limitation on the recordsource property. I solved this problem by creating a temporary table and setting the report to the temporary table, but I would rather not do this since I am not the only one creating reports.
Here is part of the query:
This is the subquery that is left joined to the project table.
Please let me know if any clarification is necessary.
Thank you in advance for helping me!
Rob
I have an interesting problem where I want to create a report using a select statement having a subquery union of several tables (partial query below). The sub union query has a variable (sPeriod) that will be set to the Period ending Date specified on the form before the user clicks view report.
Instead of coding this really long query in VB, how can I use this query as the recordsource and pass the value to the report and have it set the sPeriod variable in the subquery to the value? The where condition on openReport command only works with top level queries, at least that was my assumption as it didn't work when I tried. I cannot have the dateEntered as part of the top level query.
Another issue with coding a really long query in VB and setting it to the recordsource before opening the report is that there is a length limitation on the recordsource property. I solved this problem by creating a temporary table and setting the report to the temporary table, but I would rather not do this since I am not the only one creating reports.
Here is part of the query:
Code:
SELECT *
FROM (select id, sum(cost) as total_cost from (
select matterid as ID, Cost1+Cost2+Cost3+Cost4+Cost5 as COST
from tblActual
where dateentered <= cdate(sPeriod)
union all
select matterid as ID, Cost1+Cost2+Cost3+Cost4+Cost5 as COST
from tblMiscActual
where dateentered <= cdate(sPeriod)
union all
select client_matter_ID AS id, Invoice_total as COST
from tblInvoices
where invoice_date <= cdate(sPeriod)
union all
select client_matter_ID AS id, Invoice_total as COST
from tblInvoices where invoice_date <= cdate(sPeriod)
) group by id
) AS cost_by_project;
This is the subquery that is left joined to the project table.
Please let me know if any clarification is necessary.
Thank you in advance for helping me!
Rob