473,394 Members | 1,813 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,394 software developers and data experts.

Create Multipal Times...

I have a form with 4 text boxes; the data that is entered into them
are as follows.
Text1= Start Time
Text2= End Time
Text3= Date
Text4= Interval

I need the form to populate a table with sequential times based on the
start/end times, interval given. Then attach the same date to each
record.
For example...
Start Time = 9:00am
End Time = 12:00am
Date = 09-29-03
Interval = 5min

Result...
9:00am 09-29-03
9:05am 09-29-03
9:10am 09-29-03
9:15am 09-29-03
9:20am 09-29-03
ect...
Nov 12 '05 #1
2 1885
I'd do it in VBA like this - put the following code in the OnClick event
procedure of a CommandButton.

Private Sub cmdSetTimes_Click()

Dim db As DAO.database
Dim rs As DAO.Recordset
Dim dteCurrent As Date
Dim dteStartTime As Date
Dim dteEndTime As Date
Dim intInterval As Integer

' Don't know the name of the table you want this in...
' so used "tblTimes"
Set db = CurrentDb
Set rs = db.openrecordset("tblTimes")

' Make a Date/Time value so we can add minutes to it.
dteStartTime = CDate(Format(Me!txtDate, "m/d/yy") & _
" " & Format(Me!txtStartTime, "00:00"))

dteEndTime = CDate(Format(Me!txtDate, "m/d/yy") & _
" " & Format(Me!txtEndTime, "00:00"))

intInterval = Me!txtInterval
dteCurrent = dteStartTime

With rs
Do While dteCurrent <= dteEndTime
.AddNew
!IntervalDate = dteCurrent
.Update
dteCurrent = DateAdd("n", intInterval, dteStartTime)
intInterval = intInterval + Me!txtInterval
Loop
End With

rs.Close
db.Close

End Sub

I Changed your TextBox name "Date" to "txtDate" to avoid confusion with
Date in VBA, which is the function Date().

You'll probably have to clear out the table tblTimes before running this
routine. If so just put db.Execute "DELETE * FROM tblTimes" before the
"With rs" statement.

See the Access help topics on Do...Loops, DAO AddNew and Update,
Recordsets and anything else you don't understand in the routine.

HTH,

MGFoster
Oakland, CA (USA)
Josh Armstrong wrote:
I have a form with 4 text boxes; the data that is entered into them
are as follows.
Text1= Start Time
Text2= End Time
Text3= Date
Text4= Interval

I need the form to populate a table with sequential times based on the
start/end times, interval given. Then attach the same date to each
record.
For example...
Start Time = 9:00am
End Time = 12:00am
Date = 09-29-03
Interval = 5min

Result...
9:00am 09-29-03
9:05am 09-29-03
9:10am 09-29-03
9:15am 09-29-03
9:20am 09-29-03
ect...


Nov 12 '05 #2
jo***********@socal.rr.com (Josh Armstrong) wrote in message news:<b6**************************@posting.google. com>...
I have a form with 4 text boxes; the data that is entered into them
are as follows.
Text1= Start Time
Text2= End Time
Text3= Date
Text4= Interval

I need the form to populate a table with sequential times based on the
start/end times, interval given. Then attach the same date to each
record.
For example...
Start Time = 9:00am
End Time = 12:00am
Date = 09-29-03
Interval = 5min
Child's play
CREATE TABLE TimesList(
StartTime DATE PRIMARY KEY,
EndTime DATE NOT NULL)

Create an UNBOUND form (no recordsource) with textboxes for this stuff: Start Time = 9:00am
End Time = 12:00am
Date = 09-29-03
Interval = 5

Interval Size="n";"Minutes";"h";"Hours";"ddd","Days" (it's a combobox...)

dim db as dao.database
dim rs as dao.recordset

set db=currentdb
set rs = db.openrecordset("TimesList",dbOpenTable)
for dtThisTime = dtStart To dtFinish
rs.AddNew
rs.Fields("StartTime")=dtThisTime
rs.Fields("EndTime")=DateAdd(Me.cboInterval,dtThis Time,me.txtIntervalSize)
dtThisTime=DateAdd(Me.cboInterval,dtThisTime,me.tx tIntervalSize)
rs.Update
next dtThisTime

rs.close
set rs=nothing
set db=nothing

End sub
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: joshsackett | last post by:
Given the following table information: HOSTNAME DATETIME WEBNYC001 2005-06-15 10:30AM WEBNYC001 2005-06-15 10:31AM WEBNYC001 2005-06-15 10:31AM WEBNYC001 2005-06-15 10:34AM...
14
by: aaron kempf | last post by:
I find that ADP does not support any Stored Procedures that use the 'CREATE PROC spHAPPY' syntax. CREATE PROC syntax is listed in books online. This syntax should be supported Here is a...
3
by: Grey | last post by:
I know i can use placeholder control for dynamic create controls. but my requirement is i need to create multiple controls. when the user click the button, one textbox will be created. If user...
10
by: ANTISPAM_garycnew_ANTISPAM | last post by:
I am trying to create/update a Php Session with Javascript to confirm if users have Javascript enabled. My first thought was to create a Javascript that writes a script tag referencing a php...
4
by: BLob | last post by:
Hi, I need to create an RTF document with PHP. Actually, I am using an already created RTF document which with strings like %var% that I replace with $var before sending the document. I need to...
4
by: Paul Marrero | last post by:
Hello all. I just got a new computer and loaded Visual Studio 2003 (with SP 1). I have tried numerous times to create an ASP.NET project to no avail. Whenever I try to create a project, VS hangs...
6
by: asif929 | last post by:
I have been trying to create this chess program from many hours and still couldn't figure out how to complete it. After consume all these efforts i come here for the first time for help. i would...
7
by: Bilz | last post by:
I am planning to use the CSharpCodeProvider to generate some compiled functions in my app. In my current implementation, All of these functions are generated in one swipe... thus they all invoke...
0
by: tiingshii | last post by:
i have this working ----- http://pddesignstudio.com/ckc/php2 now i want to create spacing between each school how do i do it? can anyone help mi its my first time dealing with php PHP CODE ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.