473,378 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Sum a column of values from a query in a form field

MX1
I have a query written in MS Access that has a few calculated fields. Is it
possible to refer to that query in a form field. I'd like the form field to
show the sum of one of the columns from the query I've written. I've tried
to put the following in the form field's control source property but I'm
getting an error. Query1 is the name of the query and CalculatedTotal is
the calc'd field column I'm trying to get a total for in the form field.

=Sum([Query1]!CalculatedTotal)

Many Thanks.
Nov 12 '05 #1
3 28969
MX1
Thanks Rick. I had never seen DSUM used in that context before. It worked
like a charm. You're awesome!

Thanks again!
"Rick Brandt" <RB*****@Hunter.Com> wrote in message
news:bj************@ID-98015.news.uni-berlin.de...
"MX1" <mx*@mx1.abc> wrote in message
news:YV*********************@rwcrnsc51.ops.asp.att .net...
I have a query written in MS Access that has a few calculated fields. Is it possible to refer to that query in a form field. I'd like the form field to show the sum of one of the columns from the query I've written. I've tried to put the following in the form field's control source property but I'm
getting an error. Query1 is the name of the query and CalculatedTotal is the calc'd field column I'm trying to get a total for in the form field.

=Sum([Query1]!CalculatedTotal)
The standard aggregate functions only work on the current bound RecordSet

and the aggregation is based on where they are used (Group Header/Footer, Form Header/Footer, etc.). In your case Sum([CalculatedTotal) would work if the form was actually bound to the query [Query1] and you placed the control in either the Form Header or Form Footer.

If your form is bound to a different data source and you just want to display this sum on your form then you need to use a Domain Aggregate function as these provide an argument for the DataSource to look at. In your case...

=DSum("[CalculatedTotal]", "[Query1]")

...should work. Domain Aggregate function have no concern about their placement either. You could place the control anywhere you like on your form and it will return the same result.

Nov 12 '05 #2
MX1
One more question, I'd like to make the new calcualted form field only add
records associated with the client currently selected on the form. As I
scroll through the clients, I'd like the DSUM to change accordingly. I'm
wondering if I should filter at the original query or the fields on the
form? Any thoughts?
"MX1" <mx*@mx1.abc> wrote in message
news:7m*******************@rwcrnsc52.ops.asp.att.n et...
Thanks Rick. I had never seen DSUM used in that context before. It worked like a charm. You're awesome!

Thanks again!
"Rick Brandt" <RB*****@Hunter.Com> wrote in message
news:bj************@ID-98015.news.uni-berlin.de...
"MX1" <mx*@mx1.abc> wrote in message
news:YV*********************@rwcrnsc51.ops.asp.att .net...
I have a query written in MS Access that has a few calculated fields. Is it possible to refer to that query in a form field. I'd like the form field to show the sum of one of the columns from the query I've written. I've tried to put the following in the form field's control source property but I'm getting an error. Query1 is the name of the query and CalculatedTotal is the calc'd field column I'm trying to get a total for in the form field.
=Sum([Query1]!CalculatedTotal)
The standard aggregate functions only work on the current bound

RecordSet and the
aggregation is based on where they are used (Group Header/Footer, Form Header/Footer,
etc.). In your case Sum([CalculatedTotal) would work if the form was

actually bound
to the query [Query1] and you placed the control in either the Form

Header or Form
Footer.

If your form is bound to a different data source and you just want to display this
sum on your form then you need to use a Domain Aggregate function as

these provide an
argument for the DataSource to look at. In your case...

=DSum("[CalculatedTotal]", "[Query1]")

...should work. Domain Aggregate function have no concern about their placement
either. You could place the control anywhere you like on your form and

it will
return the same result.


Nov 12 '05 #3
MX1
All set, I filtered by ClientID on the dsum in the form and it worked. The
problem was that I didn't have ClientID selected as a field in the original
query. Thanks again!
"MX1" <mx*@mx1.abc> wrote in message
news:lB*********************@rwcrnsc51.ops.asp.att .net...
One more question, I'd like to make the new calcualted form field only add
records associated with the client currently selected on the form. As I
scroll through the clients, I'd like the DSUM to change accordingly. I'm
wondering if I should filter at the original query or the fields on the
form? Any thoughts?
"MX1" <mx*@mx1.abc> wrote in message
news:7m*******************@rwcrnsc52.ops.asp.att.n et...
Thanks Rick. I had never seen DSUM used in that context before. It worked
like a charm. You're awesome!

Thanks again!
"Rick Brandt" <RB*****@Hunter.Com> wrote in message
news:bj************@ID-98015.news.uni-berlin.de...
"MX1" <mx*@mx1.abc> wrote in message
news:YV*********************@rwcrnsc51.ops.asp.att .net...
> I have a query written in MS Access that has a few calculated
fields.
Is it
> possible to refer to that query in a form field. I'd like the form

field to
> show the sum of one of the columns from the query I've written.
I've tried
> to put the following in the form field's control source property but I'm > getting an error. Query1 is the name of the query and
CalculatedTotal is
> the calc'd field column I'm trying to get a total for in the form

field. >
> =Sum([Query1]!CalculatedTotal)

The standard aggregate functions only work on the current bound

RecordSet
and the
aggregation is based on where they are used (Group Header/Footer, Form

Header/Footer,
etc.). In your case Sum([CalculatedTotal) would work if the form was

actually bound
to the query [Query1] and you placed the control in either the Form

Header
or Form
Footer.

If your form is bound to a different data source and you just want to

display this
sum on your form then you need to use a Domain Aggregate function as

these
provide an
argument for the DataSource to look at. In your case...

=DSum("[CalculatedTotal]", "[Query1]")

...should work. Domain Aggregate function have no concern about their

placement
either. You could place the control anywhere you like on your form

and it
will
return the same result.



Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mike | last post by:
Ok, I have a page that queries a database and retrieves values to create a custom report in ms excel format on the fly so that it can be downloaded. I can use the following sub to generate the...
20
by: Steve Jorgensen | last post by:
Hi all, I've just finished almost all of what has turned out to be a real bear of a project. It has to import data from a monthly spreadsheet export from another program, and convert that into...
1
by: Steve | last post by:
I have looked through the newsgroup for an answer to this but haven't been able to find anything resembling my situation. What I want to do is relatively simple, I think. I have a crosstab...
3
by: ssb | last post by:
Hello, This may be very elementary, but, need help because I am new to access programming. (1) Say, I have a column EMPLOYEE_NAME. How do I fetch (maybe, cursor ?) the values one by one and...
13
by: nyt | last post by:
I have a problem of number and text field. I got the database file(mdb) that contains many combo boxes used and its list values are created by "value list" For eg field Field name= 'furniture'...
6
by: Steve | last post by:
I realize that this probably isn't a best practice, but I'm working with legacy code that has a query stored in one column of a table. Because the queries vary, the JSP page that selects a query...
1
by: Jimmy Stewart | last post by:
I have a continuous form has an unbound field named "Client". Its controlsource is " =.(1) " This allows me to display the client name without the combo box dropdown arrow. I want users to be able...
2
by: Exick | last post by:
This is more of a minor annoyance/curiosity than a real problem, but I'm wondering if anyone here can provide some answers. I have a form bound to a table with lots of controls on it that are...
0
by: Clare CAVS | last post by:
I have a table with a lookup column referring to another table . tblRooms has two fields, (Autonumber), and . The column I want to display is the RoomName column. If I have Bound Column = 1,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.