timing an event

wort0987654321

Registered User.
Local time
Today, 07:42
Joined
Dec 5, 2002
Messages
90
i am completing my a level it course at the minute. i am basing my project on a snooker club. the problem is that i want to calculate the time that a person has been playing for and convert it into cash that they must pay. i want my system to put a person start of time play in (e.g. 11:30) and then to put in the time that they finish (e.g. 13:30) i want the computer to work out the total amount of time played in minutes (e.g. 120) and then i can work out the total amount that they must pay, i have done it like this as the club charges 5p per minute. this is mainly so that i can get an exact amount of money that the player owes to the club.
thanks for any information that can be supplied.
 
If the StartTime and EndTime are stored in two date/time fields in a table, you can calculate the time played in minutes (in a query or on a form) using the expression:-
DateDiff("n", [StartTime], [EndTime])

and multiply it by the unit charge to get the amount owing.

As an illustration, I have attached a simple DB. When the EndTime is entered on the input form, the time in minutes and the amount owing are automatically filled in.

The code is in the After Update event of the text box EndTime (the word Me refers to the form):
----------------------------------
Private Sub EndTime_AfterUpdate()

Me.TimeInMinutes = DateDiff("n", Me.StartTime, Me.EndTime)
Me.Amount = Me.TimeInMinutes * 0.05

End Sub
----------------------------------

As it is shown by the second record on the form, if the time spans between two days, you will need to enter the dates as well.

Hope it helps.


(The attached DB is in Access97 format. If you use Access 2000, choose Convert when you open it for the first time and save with a new name.)
 

Attachments

Users who are viewing this thread

Back
Top Bottom