473,811 Members | 2,767 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1908
I'd do it in VBA like this - put the following code in the OnClick event
procedure of a CommandButton.

Private Sub cmdSetTimes_Cli ck()

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.openrecordse t("tblTimes")

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

dteEndTime = CDate(Format(Me !txtDate, "m/d/yy") & _
" " & Format(Me!txtEn dTime, "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***********@s ocal.rr.com (Josh Armstrong) wrote in message news:<b6******* *************** ****@posting.go ogle.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";"Minut es";"h";"Hours" ;"ddd","Days " (it's a combobox...)

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

set db=currentdb
set rs = db.openrecordse t("TimesList",d bOpenTable)
for dtThisTime = dtStart To dtFinish
rs.AddNew
rs.Fields("Star tTime")=dtThisT ime
rs.Fields("EndT ime")=DateAdd(M e.cboInterval,d tThisTime,me.tx tIntervalSize)
dtThisTime=Date Add(Me.cboInter val,dtThisTime, me.txtIntervalS ize)
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
1816
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 WEBNYC001 2005-06-15 10:35AM WEBNYC001 2005-06-15 10:35AM WEBNYC002 2005-06-15 10:30AM
14
3655
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 scenario: 1) create proc using query analyzer and CREATE PROC spHAPPY syntax 2) open this proc in ADP
3
1529
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 click three times, there will be three textbox created. However, just only one textbox was created whatever times I click. PLs help. Million thanks
10
3931
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 page, which sets a $_SESSION variable. javascript.js: <script type="text/javascript"> <!--//
4
9593
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 create a link like http://www.example.com/id_content=125 but my problem is that in the document produced : I can read http://www.example.com/id_content=125 But if I click on the link it goes to
4
4943
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 for a minute or two then displays this error: The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/WebApplication1'. 'The operation timed out'. I have...
6
3107
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 appreciate if somebody help me out of this to debug the program below. The chess board suppose to be printed with "*" and space " " as you can see below as an example. Again I would appreciate for your help in advance. sample print or output:
7
2552
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 the compiler once, and create only one DLL. My new requirement tells me that I need to be more dynamic... that I can't queue up all of these functions... I actually need to do them more on demand. The number of times this happens can be as...
0
1469
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 1. <span class="style2"> 2. <style type="text/css"> 3. <!-- 4. body, th, td, p, small {
0
9727
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10386
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9204
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7669
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.