开发者

MS Access - using multiple queries in 1 report

I have about 35 queries in a large MS Access (2007) database that I would like to use in a report. However, I don't want to create reports for each query, but would rather include multiple queries in one report. The other questions relating to this on SO seem to be related to tables, but I am mainly concerned with开发者_运维技巧 just queries.

I have looked at several solutions so far, none of which seem to help:

1) DLookup - returns one value. I need to populate a report with many values from each query.

2) Subreports - I have tried to create text boxes to link my query data, but since they are unbound, it won't let me.

3) Yelling at it. I keep yelling at Access and it doesn't seem to help.

4) One giant query to get the values from all the smaller queries - it doesn't recognize the expressions I built in the smaller queries. Example: CustomerCount = DCount("[Customer_ID]","[Customers]"). Error: 'CustomerCount' is unrecognized.

Any ideas would be greatly appreciated.

Thanks,


If you are creating a report from one query that is made up of multiple subqueries, you can do this by populating textboxes. If looking at the properties on the report > Data tab > Control Source, you would place the name of the your subquery from your giant query and then the value you that you want.

For example:

Master query

    SELECT 
        [Deb<30].CountOfACCT_ID, [Deb<30].SumOfB001, 
        [Deb<60].CountOfACCT_ID, [Deb<60].SumOfB001, 
        [Deb<90].CountOfACCT_ID, [Deb<90].SumOfB001, 
        [Deb>90].CountOfACCT_ID, [Deb>90].SumOfB001, 
        TodaysHD.CountOfACCT_ID, TodaysHD.SumOfB001, 
        TodaysLD.CountOfACCT_ID, TodaysLD.SumOfB001, 
        Part.CountOfACCT_ID, Part.SumOfB001, 
    FROM [Deb<30], [Deb<60], [Deb<90], [Deb>90], TodaysHD, TodaysLD, Part;

Each of the items in the FROM portion are subqueries being pulled into the master query. Then in your report you would populate the Control Source with [Deb<30].CountOfACCT_ID or whatever value you need from the master query. I have this setup in multiple reports in my application so it should work.


as for 2) you should be able to bind your controls, your subreport should have a record-source.

Else, try listboxes, their graphical apperance isn't exactly flexible, but they might get the job done.

regards, //t

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜