开发者

Building a Access Report from a query

I have a query that has 3 columns: Payment Method, Count, Amount. When I try to create my report to bring in the data from the query, if a payment method has more than one in the count column it shows up as zero on my report for the count and the total. I am using the following in expression builder to bring in the data from the query:

for the number of the specific payments

=Sum(IIf([paymethod]="Discover",[Count],0)) 

for the total amount of all payments

=Sum(IIf([paymethod]="Discover",[Total],0开发者_JAVA技巧)) 

The SQL behind the report

SELECT qryDailyDeposit.Count, qryDailyDeposit.Total, qryDailyDeposit.paymethod
FROM [qryTotal Deposit], qryDailyDeposit;


I guess your query with JOIN and Count(*) causes issues. Regardless, the following setup should guard you against unexpected results:

  • Payment Methods table:

    Building a Access Report from a query

  • Payments table:

    Building a Access Report from a query

  • Query:

    Building a Access Report from a query

  • Query results:

    Building a Access Report from a query

Now, just use the above query as datasource for your report:

  • Report datasource:

    Building a Access Report from a query

  • Report preview:

    Building a Access Report from a query


Make a new query to bind to the report:

SELECT paymethod, sum(amount) as [Amount], count(*) as [Total Payments] FROM yourTransactionTable GROUP BY paymethod ORDER BY paymethod

Once that's bound to your report you should be able to use a query wizard to build a quick report or design your own by dragging the bound fields over.

I'm guessing the reason you're getting 0 entry text boxes is that the report is going through each row returned by the query and on rows where the paymethod isn't "Discover", for example, it just outputs 0.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜