By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,486 Members | 2,169 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,486 IT Pros & Developers. It's quick & easy.

calculating the sum of a field in using access forms.

P: 3
Dear All
i have the following problem and i am using microsoft access 2000 forms:-
i am working on a system for a store, and i have a table named orders (order id , order_date , order_price, order_company_owner_name), and i have created a form for this table , what i am trying to do is that i want to add a field that calculate the sum of the prices for all the retrived orders (order_price) column for all the orders on the form that will be retrived after filtering the records (records - filter - filter by form) and i want the sum of those records to be calculted once the user click on the calculate button ?
thanks in advance
Sep 19 '07 #1
Share this Question
Share on Google+
6 Replies


puppydogbuddy
Expert 100+
P: 1,923
Dear All
i have the following problem and i am using microsoft access 2000 forms:-
i am working on a system for a store, and i have a table named orders (order id , order_date , order_price, order_company_owner_name), and i have created a form for this table , what i am trying to do is that i want to add a field that calculate the sum of the prices for all the retrived orders (order_price) column for all the orders on the form that will be retrived after filtering the records (records - filter - filter by form) and i want the sum of those records to be calculted once the user click on the calculate button ?
thanks in advance
Use the DSum function over your filtered domain:

DSum("[order_price]", "YourFilteredQuery")

Or use DSum with where clause (see example below)

DSum("[order_price]", "YourBaseQuery", "order_date < Xdate")
Sep 19 '07 #2

lee123
100+
P: 556
on the footer of the form add a text box in design view go to the properties of the text box find the controlsource and put this in the controlsource:

=sum(orderprice)

lee123
Sep 19 '07 #3

P: 3
on the footer of the form add a text box in design view go to the properties of the text box find the controlsource and put this in the controlsource:

=sum(orderprice)

lee123
Many thnaks it works well , but i need to calculate the sum only when the user clicks on a button, not automatically.
Sep 19 '07 #4

P: 3
any advice on how to calculate the sum of the prices only when i press on the calculate button???
Sep 20 '07 #5

puppydogbuddy
Expert 100+
P: 1,923
any advice on how to calculate the sum of the prices only when i press on the calculate button???

Here is one way that might work:
1. Set the visible property of the textbox with the calc to no in the forms current event.
2. Make it visible when you click the button:

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourButton_Click()
  2. Me.YourTextbox.Visible = True
  3. End Sub
  4.  
  5. Private Sub Form_Current()
  6. Me.YourTextbox.Visible = False
  7. End Sub
Sep 20 '07 #6

puppydogbuddy
Expert 100+
P: 1,923
If you don;t want the calc to occur, visible or not, substitute enabled for visible in the above code.
Sep 20 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.