Karen,
While your database is a work in progress, you ought to consider changing your
tables ---
TblRoomType
RoomTypeID
RoomType
WeekDayRate
WeekEndRate
TblRoom
RoomID
RoomNum
RoomTypeID
TblRoomBooking
RoomBookingID
RoomID
StartDate
EndDate
Next Put These two functions in a standard module:
Function CountWeekDays(FirstDay,LastDay) As Integer
Dim BookingDay As Date
CountWeekDays = 0
BookingDay = FirstDay
Do Until BookingDay = LastDay
If WeekDay(BookingDay) <> vbSaturday And WeekDay(BookingDay) <> VbSunday
Then
CountWeekDays = CountWeekDays + 1
End If
BookingDay = BookingDay + 1
Loop
End Function
Function CountWeekEndDays(FirstDay,LastDay) As Integer
Dim BookingDay As Date
CountWeekEndDays = 0
BookingDay = FirstDay
Do Until BookingDay = LastDay
If WeekDay(BookingDay) = vbSaturday Or WeekDay(BookingDay) = VbSunday Then
CountWeekEndDays = CountWeekEndDays + 1
End If
BookingDay = BookingDay + 1
Loop
End Function
Next create a query that joins the three tables and includes the fields,
RoomNum, StartDate and EndDate. In the first empty field in the query put:
NumWeekDays:CountWeekDays(StartDate,EndDate)
In the next empty field put:
NumWeekEndDays:CountWeekEndDays(StartDate,EndDate)
In the next empty field put:
WeekDayRevenue:[NumWeekDays]*[WeekDayRate]
In the next empty field put:
WeekEndRevenue:[NumWeekEndDays]*[WeekEndyRate]
In the next empty field put:
TotalRevenue:[WeekDayRevenue]+[WeekEndRevenue]
You can now use this query in a variety of ways. For instance you could get the
total revenue for a room for a month or you could get the total revenue for a
group of rooms for a month.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
www.pcdatasheet.com
Karen Huynh said:
Hi
I was wondering if it is possible for access to determine if the nights the
customer's staying are weekdays or weekends. I have two fields in the table
that have StartDate, EndDate and Rmtype that is linked with another table
which has Rmtype, WeekendPrice and Wkdayprice.
I would like access to recognise the days that fall between the StartDate
and EndDate and calculate a subtotal.
eg. Customer's StartDate is 12/10/2003 and EndDate is 15/10/2003. The Rmtype
is "Family" and the WkendPrice is $70 and WkdayPrice is $90.
I want access to realise that 12/10/2003 is Sunday so it charges the
customer wkendprice of $70 then the following 2 days (15th is the day guest
checks out so it doesn't get counted) is $90. This will appear in a textbox
"RoomCost" in the form "invoices"
I hope i've explained myself properly.
If anyone can help, that would be greatly appreciated.
Thank you in advance