Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 1st, 2008, 10:41 AM
Authorized User
 
Join Date: Mar 2006
Posts: 83
Thanks: 1
Thanked 0 Times in 0 Posts
Default Dividing Two Running Sums in a Report

Hello!

I have a report which has two running sum fields - and what I am trying to do is to divide one of them by the other. Here is a sample of how the report should look eventually:

Day CostToday CostToDate SalesToday SalesToDate RatioToday RatioToDate
1 100 100 1000 1000 10,00% 10,00%
2 200 300 3400 4400 5,88% 6,82%
3 150 450 2100 6500 7,14% 6,92%

CostToDate is the running sum of CostToday.
SalesToDate is the running sum of SalesToday.
RatioToDate should be CostToDate divided by SalesToDate for each line - note it is not a running sum of RatioToday.

Can anyone help? Thank you!

Odeh
 
Old August 4th, 2008, 01:32 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Will the day numbers always be sequential? You can either write code to make these claculations in the report, or you can store them in your table. I would opt for storing the values in your original table. Then when the report was run, it could make your calculations, and then your arithmetic is easy.

If you are running the report on a date range, then you can store all the values in a temporary table, and base the report on that table.

Do you have a preference and other requirements?

mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old August 5th, 2008, 02:16 AM
Authorized User
 
Join Date: Mar 2006
Posts: 83
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thank you for your reply!

My tables are set up like this:

tblTransactionDate:
txtDay
txtMonth
txtYear

tblTransactions:
txtTransactionType (i.e. purchase, sale, internal transfer, etc.)
txtProductType (i.e. food, beverage, etc.)
txtFromSection
txtToSection
Amount (i.e. in Euros)

The report is a monthly report - but for example, if I only have the movements of the first three days of the month registered, the monthly report (lets say for July 2008) will only show three lines. These two table are related - one-to-many using transactionID.

For me either option is fine, as long as I can get the value to appear in the field - but I am not sure how to do any of the options that you offered - can you explain, for example, I would transfer the running sums to a temporary table?

Thank you! It isnt possible to send screenshots through this forum, is it?

Regards! Odeh
 
Old August 6th, 2008, 07:32 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You can send information directly to me using my contact information (click on my name).

Can you send me the database empty? It would be easier to see the structure and work on the solution with that.


mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old August 6th, 2008, 09:19 AM
Authorized User
 
Join Date: Mar 2006
Posts: 83
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hello Thank you for your reply.

I clicked on your name, and then on 'send email' but I didnt find any way to attach the file or screenshots. Also I didnt see any personal details.

I think you helped me out with a problem a long time ago and provided it to me - I believe I still have the address somewhere - if I find it, may I send it to you on that?

Do you prefer I attach it as a zip file? Thank you!
 
Old November 5th, 2008, 04:57 PM
pjm pjm is offline
Authorized User
 
Join Date: Jul 2006
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You should be able to create a new text field on your report and make its Control Source a ratio based on the names of the running sum fields displayed on your report.

      -Phil-
 
Old November 5th, 2008, 05:48 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Why are you answering threads that are MONTHS OLD???

The person who asked the question either got the answer or gave up. Almost surely he/she isn't going to come back months later trying to still get the answer.
 
Old November 6th, 2008, 04:47 PM
pjm pjm is offline
Authorized User
 
Join Date: Jul 2006
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did it ever occur to you that people might be browsing old messages to get some info they can use? Why do you think these messages remain?

If this so offends your sensibilities then why are you insisting on even responding to an "out of date" message?

      -Phil-
 
Old November 7th, 2008, 08:08 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Because we subscribed to them when they were current, and we are getting constantly peppered with emails with your random thoughts.



mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old November 7th, 2008, 03:37 PM
pjm pjm is offline
Authorized User
 
Join Date: Jul 2006
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I post to a newsgroup because I actually feel I have something to contribute (not like someone just saying "yes, I agree" or "me too!"). When I browse these newsgroups I want to see answers to questions and I don't care about the dates on the messages. Many times I've seen questions that were posted months ago that never received an answer.

If you have such a problem with my "random thoughts" perhaps you should do as I do by not subscribing and periodically checking for non-random thoughts.

      -Phil-





Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple users running the same report rashi Access 5 April 25th, 2008 07:48 AM
Dividing a text into 2 Columns in XSL-FO NEO1976 XSLT 0 September 19th, 2006 04:31 AM
Dividing Subtotals on a Report Corey Access 12 September 30th, 2005 11:39 AM
distinct sums.. dodorisio SQL Language 3 February 9th, 2005 08:57 AM
Dividing contents of 1 excel file into many Wire Excel VBA 1 April 12th, 2004 05:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.