473,396 Members | 2,109 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,396 software developers and data experts.

MS Access Total Calculation Query

I have two tables with one-to-many relationship.

(1) Room_Type &
(2) RateSheet

Room_Type Table (Example)

+-------------+-----------+
|Property_Name| Room_Type |
+-------------+-----------+
|Property 1 | R_Type 1 |
|Property 2 | R_Type 2 |
|Property 3 | R_Type 3 |
+-------------+-----------+

RateSheet Table (Example)

+----------+------------+------------+------+
|Room_Type | Start_Date | End_Date | Rate |
+----------+------------+------------+------+
|R_Type 1 | 01-03-2014 | 10-03-2014 | 100 |
|R_Type 1 | 11-03-2014 | 20-03-2014 | 120 |
|R_Type 1 | 21-03-2014 | 10-03-2014 | 130 |
+----------+------------+------------+------+

For each room type there is one or more rates & rates differ at different periods.

I hava a search form which will display a query result of Property Name, Room Type, Total for specific number of days.

In the form I have to enter two dates, Start Date & End Date

For example:

Start Date = 05-03-2014
End Date = 12-03-2014


Now the query should display the result similar to the table below

+---------------+-----------+-------+
| Property_Name | Room_Type | Total |
+---------------+-----------+-------+
| Property 1 | R_Type 1 | 720 |
+---------------+-----------+-------+

How total is calculated?

From 1st to 10th March, the rate is 100 per day.
From 11th to 20th March, the rate is 120 per day.

In the form I've entered 05-03-2014 as start date & 12-03-2014 as end date. So, rate is calculated for (5,6,7,8,9,10 & 11) of March (12th March not included when calculating the rate)

So, 100 is the rate for (5,6,7,8,9 & 10th March) and 120 for 11th March.

Total = (6 x 100) + (1 x 120) = 720

I want to make a query to generate this result.

Please help guys... :)
Mar 25 '14 #1
2 1013
Rabbit
12,516 Expert Mod 8TB
Two options.

1) Create a calendar table, filter for the dates you're looking for, join that to the rate sheet, and do a sum.

2) Use code to loop through your dates and get a running sum to return.
Mar 25 '14 #2
zmbd
5,501 Expert Mod 4TB
Ali Xihuny
Please understand, we can help you with specfic problems; however, we do not normally provide completed code/sql/projects.
If you will post your SQL we can help you out.

If you are very new to Access and Database design, then you really need to start out with some basic tutorials. If you would like I can PM you a set of such and other useful links - just ask and it's yours.
Mar 25 '14 #3

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

Similar topics

1
by: Peter Monica | last post by:
I am trying to calculate distance from a point entered by a user usng a function in Access in a query that calls tables in an Oracle database as well as in Access. I am getting the following...
7
by: Peter Bailey | last post by:
I have a query that returns weekly enrollments: Qrygetweeklycountofdosmoduleenrollments Week Commencing Week Ending Total Bookings 02/04/2004 02/04/2004 0 05/04/2004 09/04/2004 0 12/04/2004...
2
by: dollyvishal | last post by:
How to get constraint information for MS Access tables using Query?
9
by: jalmar | last post by:
TGIF & Good morning: Can someone please tell me why my calculation query isn't working. I will post the SQL below for your review. Thanks in advance for your help. SELECT ., ., ...
1
by: Ed244 | last post by:
Hi, I'm in the process of producing a database for a college project and have a slight problem I was wondering whether you could help me with. The area I'm having problems with takes a value...
0
by: astersathya | last post by:
Date Format in MS Access using a query Hi I want to alter the existing column's format using the alter query. The issue I am facing is I want to set the default date format of an existing...
5
by: bigredseany | last post by:
Hi, I am new to access and I am trying to create some kind of inventory database for my uncles company. Not sure how to explain this, I am trying to just 'link' the total from the bottom of the...
1
by: EORTIZ | last post by:
This is an example of what I need to do: Data in an ACCESS table: CustomerID: AAA Pay_Month: Dec-2006 Type:General Adjust_FromDate:N/a (for general payments, no adjustments) ...
4
by: student2 | last post by:
Hi :-) I'm using Ms Access 2003 to create a DB for my school project and I need to accomplish the following:- * Calculate balances for stock (inclusive of sales and replenishment to stock) ...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.