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

SQL or VBA?

P: n/a
I currently have a report based on a "Totals" select query, which is
based on 3 tables and a union query. The pertinent fields are:
Fleet No - Group By, Year([Date]) - Group By, Month([Date]) - Group
By, Start Odo - Min, Odo To Date - Max, Cost - Sum. The purpose of the
report is to establish the cost per month, total kms per month and
cost per km, per month.

The requirement is, that if there is no odometer entered that it takes
the previous month's Odo to Date - Max as the Odo - Min for the new
month, e.g.

Fleet No - Fleet1, Year - 2003, Month 02, Start Odo - 15000, Odo to
Date - 15500; Fleet No - Fleet1, Year - 2003, Month 03, Start Odo -
15500, Odo to Date - 15500; Fleet No - Fleet1, Year - 2003, Month 04,
Start Odo - 15500, Odo to Date - 15750; etc, etc. Where month 03 Start
Odo and Odo to Date were generated, as no odometers were physically
entered and Month 04's Start Odo was generated as closing odometer for
the month was entered.

In other words ...
The Start Odo for example 2003, 03 must be the previous month's (2003,
02) Odo to Date reading and, the Odo to Date reading (2003, 03) must
be the same as the Start Odo for the month (2003, 03) if no odometer
has been entered? Please note: The 1st month starts off from the 1st
entry in the table - there is always an odometer reading for the 1st
entry.
Nov 13 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.