Select Sum SQL help

B

Billy B

I am trying to create a report with a text box as a calculated control using
SQL Select statement. In the Code Header Section there is a text box control
with the a code number generated by the user when the form opens. With that
Code number, I want to sum the allocated amount based on that number and I am
trying to do that with a Select clause. What I have is not working and I have
made several other attempts without success. Maybe someone can help me.

SELECT [PO Master].Code, Sum([PO Master].Allocation) AS SumOfAllocation FROM
[PO Master] GROUP BY [PO Master].Code Where ((([PO Master].Code)="
Code:
"));
 
D

Duane Hookom

You can't use a SQL statement as a Control Source. If you want to sum a
numeric value from a report's section, use a text box with a control source
like:
=Sum([Allocation])
If for some unusual reason, you want to sum records and/or fields that
aren't part of your report's record source then you can use DSum(). I hate
DSum() and find it is often used when people don't understand how to use
Sum().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top