Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create times by intervals 1

Status
Not open for further replies.
Apr 19, 2000
73
US
I am trying to create a form that a user can input start time/stop time, then intervals in minutes that will update a table with the results.
Example:
User inputs start time 9:00 AM and stop time of 10:00 AM with 15 minute intervals.
The table would then contain
9:00 AM
9:15 AM
9:30 AM
9:45 AM
10:00 AM
What is the best way to do this. I am thinking an unbound form with an onclick event for a button but am not sure how to code this to calcuate the times.



 
Unclear if you want to add only quarter, half, three quarter and 'on the hour' times or, for example, if the person signs in at 9:10, should the next table entry be 9:25 (fifteen minutes later)? But..

You could use the form's interval timer function to calculate your times. Set the timer interval to fifteen minutes (1000 = 1 second). Then, at every timer event, fire off a procedure to either do an update query to put the time (that you want) in the table or do a procedure that actually opens the recordset and writes the time in the table for the person 'signed in'. The timer, of course, would only be doing this as long as it knew someone was 'signed on'. You could set a variable flag for this (e.g. = 1 at 'sign on' click event) and have the interval timer check for this before it does its update.

Hope this helps. Good Luck


 
Hop e this clears it up a little on what I'm looking for.

(start time field, stop time field and populate a table with those 2 times and every time in between based on the number of minute intervals the user inputs so the user does not have to manually enter each time into a table.)

It's for appointment scheduling. Example:
User john doe's start time for appointments today is 9:00 AM until 10:00 AM and each apppointment is scheduled 15 minutes apart starting at 9:00 am and ending at 10:00 AM
So User John Doe enters his start/stop times and increment of 15 minutes, and then (i assume) click a button labeled update (on click event) and the underlaying table populates with every time starting at 9:00 am to 10:00 am in 15 minute intervals.

User John Doe's appointment start/stop times and duration may change at any given day. If he worked 10 hours on a given day with appointments in 10 minute intervals, it would get very tedious inputing 9:00am 9:10 am 9:20 am etc. etc. every time he changes appointment lengths or start/stop times. yikes! :)
Once the table is populated I can lookup to it in a combo box or something on another form to select which times are available for any given day.

 
I think that he wants to take the starttime and the endtime and for each interval requested, add the times. So, if the user enters 9:10 to 10:40 with an interval of 10 minutes it would create and enter:

9:10
9:20
9:30
....
10:40

But I couldn't see a way of doing it easily. Am still pondering and waiting to see a solution!

leslie
 
Can you simply loop from start time to end time using the interval time as the step, then inside the loop, using the DateAdd function adding the interval to the 'current time', and appending the records accordingly.

currtime = start_time
from start_time to end_time step interval
Append Record using currtime
currtime = DateAdd("n", interval, currtime)
next

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
That's exactly what I'm talking about Lespaul, thanks for the abriged version of what I was trying to get at. Now if any kind guru's out there can assist??? :)
 
Very Cool CC!

I tried doing something similar with dates the other day (in Delphi) and couldn't get it to work with the TDateTime field as the control for the loop.

Have a star on me!

les
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top