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

need help with inserting a set of records

Hello all & I hope I'm posting in the right place..

I need to load a temporary table with a range of sequential dates,
passing it a beginning and an end date from a criteria form.

I have created the form FrmMakeDayFile with 2 unbound fields
[txtDateFr] and [TxtDateTo]. I simply want to be able to click a
button and have a routine of some sort append records to the table
tblDates with field Ddate inserted starting from txtDateFr and adding
a new record for each date, ending at TxtdateTo. (This data gets used
in a local front-end and is then zapped... but that part's under
control - I just need to quickly seed values to the dayfile table....)

I must be having a vague day as something that shoudld so easy is
eluding me... Can anybody start me off please.

thankyou.
Dave
Jun 27 '08 #1
8 1414
mvdave wrote:
Hello all & I hope I'm posting in the right place..

I need to load a temporary table with a range of sequential dates,
passing it a beginning and an end date from a criteria form.

I have created the form FrmMakeDayFile with 2 unbound fields
[txtDateFr] and [TxtDateTo]. I simply want to be able to click a
button and have a routine of some sort append records to the table
tblDates with field Ddate inserted starting from txtDateFr and adding
a new record for each date, ending at TxtdateTo. (This data gets used
in a local front-end and is then zapped... but that part's under
control - I just need to quickly seed values to the dayfile table....)

I must be having a vague day as something that shoudld so easy is
eluding me... Can anybody start me off please.

thankyou.
Dave
Depends on what you already know how to do and what you don't. You need...

A VBA code procedure that opens an editable Recordset against your
destination table.

A Loop within that procedure.

Within the loop you create a date value one larger than the previous loop
iteration DateAdd() function being a good mechanism here.

Within that same loop you insert the generated date into your Recordset.

You start the loop with your start date and you stop the loop after you
have inserted the value matching your end date.

Which of the above do you already know how to do and which do you need help
with?

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


Jun 27 '08 #2
On Apr 14, 2:54*am, "Rick Brandt" <rickbran...@hotmail.comwrote:
mvdave wrote:
Hello all & I hope I'm posting in the right place..
I need to load a temporary table with a range of sequential dates,
passing it a beginning and an end date from a criteria form.
I have created the form FrmMakeDayFile with 2 unbound fields
[txtDateFr] and [TxtDateTo]. I simply want to be able to click a
button and have a routine of some sort append records to the table
tblDates with field Ddate inserted starting from txtDateFr and adding
a new record for each date, ending at TxtdateTo. (This data gets used
in a local front-end and is then zapped... but that part's under
control - I just need to quickly seed values to the dayfile table....)
I must be having a vague day as something that shoudld so easy is
eluding me... *Can anybody start me off please.
thankyou.
Dave

Depends on what you already know how to do and what you don't. *You need....

A VBA code procedure that opens an editable Recordset against your
destination table.

A Loop within that procedure.

Within the loop you create a date value one larger than the previous loop
iteration DateAdd() function being a good mechanism here.

Within that same loop you insert the generated date into your Recordset.

You start the loop with your start date *and you stop the loop after you
have inserted the value matching your end date.

Which of the above do you already know how to do and which do you need help
with?

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt * at * Hunter * dot * com- Hide quoted text -

- Show quoted text -
Thanks Rick... A programmer i ain't.. but here's where i got to with
it..which has elementrs of what you've advised. But it's not working..
I'm sure there's somthing simpler.

Dim sdate As Date
Dim edate As Date
Dim Ddate As Date

Dim rstDayfile As Recordset
Dim db As Database
Dim sqldates As String

Set db = CurrentDb()
sqldates = "select * from TblDates"
Set rstDayfile = db.OpenRecordset(sqldates, dbOpenDynaset)
sdate = Me.txtFromDate
edate = Me.txtToDate
Ddate = DMax("ddate", "tbldates")

With rstDayfile
Do Until Ddate edate
Ddate = sdate
AddNew
!Ddate = sdate + 1
Update
Loop
End With
Jun 27 '08 #3
mvdave wrote:
Hello all & I hope I'm posting in the right place..

I need to load a temporary table with a range of sequential dates,
passing it a beginning and an end date from a criteria form.

I have created the form FrmMakeDayFile with 2 unbound fields
[txtDateFr] and [TxtDateTo]. I simply want to be able to click a
button and have a routine of some sort append records to the table
tblDates with field Ddate inserted starting from txtDateFr and adding
a new record for each date, ending at TxtdateTo. (This data gets used
in a local front-end and is then zapped... but that part's under
control - I just need to quickly seed values to the dayfile table....)

I must be having a vague day as something that shoudld so easy is
eluding me... Can anybody start me off please.

thankyou.
Dave
I might have a command button to initiate the append. Air code
Dim datFor As date
Dim rst As Recordset
set rst = Currentdb.openrecordset("TableName",dbopendynaset)
It Not IsNull(Me.FromDate) And Not IsNull(Me.ToDate) then
For datFor = Me.FromDate to Me.ToDate
rst.Addnew
rst!TableDateField = datFor
rst.Update
Next
Endif

Soon is now
http://www.youtube.com/watch?v=K2NrIALcNOw
Jun 27 '08 #4
mvdave wrote:
On Apr 14, 2:54 am, "Rick Brandt" <rickbran...@hotmail.comwrote:
>mvdave wrote:
>>Hello all & I hope I'm posting in the right place..
>>I need to load a temporary table with a range of sequential dates,
passing it a beginning and an end date from a criteria form.
>>I have created the form FrmMakeDayFile with 2 unbound fields
[txtDateFr] and [TxtDateTo]. I simply want to be able to click a
button and have a routine of some sort append records to the table
tblDates with field Ddate inserted starting from txtDateFr and
adding a new record for each date, ending at TxtdateTo. (This data
gets used in a local front-end and is then zapped... but that
part's under control - I just need to quickly seed values to the
dayfile table....)
>>I must be having a vague day as something that shoudld so easy is
eluding me... Can anybody start me off please.
>>thankyou.
Dave

Depends on what you already know how to do and what you don't. You
need...

A VBA code procedure that opens an editable Recordset against your
destination table.

A Loop within that procedure.

Within the loop you create a date value one larger than the previous
loop iteration DateAdd() function being a good mechanism here.

Within that same loop you insert the generated date into your
Recordset.

You start the loop with your start date and you stop the loop after
you have inserted the value matching your end date.

Which of the above do you already know how to do and which do you
need help with?

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com- Hide quoted text -

- Show quoted text -

Thanks Rick... A programmer i ain't.. but here's where i got to with
it..which has elementrs of what you've advised. But it's not working..
I'm sure there's somthing simpler.

Dim sdate As Date
Dim edate As Date
Dim Ddate As Date

Dim rstDayfile As Recordset
Dim db As Database
Dim sqldates As String

Set db = CurrentDb()
sqldates = "select * from TblDates"
Set rstDayfile = db.OpenRecordset(sqldates, dbOpenDynaset)
sdate = Me.txtFromDate
edate = Me.txtToDate
Ddate = DMax("ddate", "tbldates")

With rstDayfile
Do Until Ddate edate
Ddate = sdate
AddNew
!Ddate = sdate + 1
Update
Loop
End With
Try...

Dim edate As Date
Dim NewDate As Date
Dim rstDayfile As Recordset
Dim db As Database
Dim sqldates As String

Set db = CurrentDb()
sqldates = "select * from TblDates"
Set rstDayfile = db.OpenRecordset(sqldates, dbOpenDynaset)
NewDate = Me.txtFromDate
edate = Me.txtToDate

With rstDayfile
Do Until NewDate edate
.AddNew
!Ddate = NewDate
.Update
NewDate = DateAdd("d", 1, NewDate)
Loop
End With

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Jun 27 '08 #5
On Apr 14, 3:24*am, Salad <o...@vinegar.comwrote:
mvdave wrote:
Hello all & I hope I'm posting in the right place..
I need to load a temporary table with a range of sequential dates,
passing it a beginning and an end date from a criteria form.
I have created the form FrmMakeDayFile with 2 unbound fields
[txtDateFr] and [TxtDateTo]. I simply want to be able to click a
button and have a routine of some sort append records to the table
tblDates with field Ddate inserted starting from txtDateFr and adding
a new record for each date, ending at TxtdateTo. (This data gets used
in a local front-end and is then zapped... but that part's under
control - I just need to quickly seed values to the dayfile table....)
I must be having a vague day as something that shoudld so easy is
eluding me... *Can anybody start me off please.
thankyou.
Dave

I might have a command button to initiate the append. *Air code
* * * * Dim datFor As date
* * * * Dim rst As Recordset
* * * * set rst = Currentdb.openrecordset("TableName",dbopendynaset)
* * * * It Not IsNull(Me.FromDate) And Not IsNull(Me.ToDate) then
* * * * * * * * For datFor = Me.FromDate to Me.ToDate
* * * * * * * * * * * * rst.Addnew
* * * * * * * * * * * * rst!TableDateField = datFor
* * * * * * * * * * * * rst.Update
* * * * * * * * Next
* * * * Endif

Soon is nowhttp://www.youtube.com/watch?v=K2NrIALcNOw- Hide quoted text -

- Show quoted text -
OK - thankyou Salad!!

Here' the tidied version of your air code... Worked a treat! Thankyou
very much. It's 3:40 am here... time for some zzzzz's. Much
appreciated. Dave.

Private Sub CmdMakeDayFile_Click()

Dim datFor As Date
Dim rst As Recordset

Set rst = CurrentDb.OpenRecordset("tblDates", dbOpenDynaset)

If Not IsNull(Me.txtFromDate) And Not IsNull(Me.txtToDate) Then
For datFor = Me.txtFromDate To Me.txtToDate
rst.AddNew
rst!Ddate = datFor
rst.Update
Next
End If

End Sub
Jun 27 '08 #6
On Sun, 13 Apr 2008 09:33:11 -0700 (PDT), mvdave wrote:
Hello all & I hope I'm posting in the right place..

I need to load a temporary table with a range of sequential dates,
passing it a beginning and an end date from a criteria form.

I have created the form FrmMakeDayFile with 2 unbound fields
[txtDateFr] and [TxtDateTo]. I simply want to be able to click a
button and have a routine of some sort append records to the table
tblDates with field Ddate inserted starting from txtDateFr and adding
a new record for each date, ending at TxtdateTo. (This data gets used
in a local front-end and is then zapped... but that part's under
control - I just need to quickly seed values to the dayfile table....)

I must be having a vague day as something that shoudld so easy is
eluding me... Can anybody start me off please.

thankyou.
Dave


Copy and paste the below code into a Module.
Open your form and enter the 2 dates.
Run the Code.

Public Sub FillDates()
' Will fill a Date Field with consecutive date values.

Dim db As DAO.Database
Dim rs As Recordset
Dim dteFrom As Date
Dim dteTo As Date
Set db = CurrentDb
Set rs = db.OpenRecordset("tblDates")
dteFrom = Forms!FrmMakeDayFile![txtDateFr]
dteTo = Forms!FrmMakeDayFile![txtDateTo]

With rs
Do Until dteFrom = dteTo + 1
.AddNew
!Ddate = dteFrom
.Update
dteFrom = dteFrom + 1
Loop
End With
Set db = Nothing
Set rs = Nothing
End Sub
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Jun 27 '08 #7
mvdave wrote:
On Apr 14, 3:24 am, Salad <o...@vinegar.comwrote:
>>mvdave wrote:
>>>Hello all & I hope I'm posting in the right place..
>>>I need to load a temporary table with a range of sequential dates,
passing it a beginning and an end date from a criteria form.
>>>I have created the form FrmMakeDayFile with 2 unbound fields
[txtDateFr] and [TxtDateTo]. I simply want to be able to click a
button and have a routine of some sort append records to the table
tblDates with field Ddate inserted starting from txtDateFr and adding
a new record for each date, ending at TxtdateTo. (This data gets used
in a local front-end and is then zapped... but that part's under
control - I just need to quickly seed values to the dayfile table....)
>>>I must be having a vague day as something that shoudld so easy is
eluding me... Can anybody start me off please.
>>>thankyou.
Dave

I might have a command button to initiate the append. Air code
Dim datFor As date
Dim rst As Recordset
set rst = Currentdb.openrecordset("TableName",dbopendynaset)
It Not IsNull(Me.FromDate) And Not IsNull(Me.ToDate) then
For datFor = Me.FromDate to Me.ToDate
rst.Addnew
rst!TableDateField = datFor
rst.Update
Next
Endif

Soon is nowhttp://www.youtube.com/watch?v=K2NrIALcNOw- Hide quoted text -

- Show quoted text -


OK - thankyou Salad!!

Here' the tidied version of your air code... Worked a treat! Thankyou
very much. It's 3:40 am here... time for some zzzzz's. Much
appreciated. Dave.
It appears you are a bit aways from the US. Australia?

I think you can either go to bed now or get up for the Monday commute.
>
Private Sub CmdMakeDayFile_Click()

Dim datFor As Date
Dim rst As Recordset

Set rst = CurrentDb.OpenRecordset("tblDates", dbOpenDynaset)

If Not IsNull(Me.txtFromDate) And Not IsNull(Me.txtToDate) Then
For datFor = Me.txtFromDate To Me.txtToDate
rst.AddNew
rst!Ddate = datFor
rst.Update
Next
End If

End Sub
Jun 27 '08 #8
On Apr 14, 4:25*am, Salad <o...@vinegar.comwrote:
mvdave wrote:
On Apr 14, 3:24 am, Salad <o...@vinegar.comwrote:
>mvdave wrote:
>>Hello all & I hope I'm posting in the right place..
>>I need to load a temporary table with a range of sequential dates,
passing it a beginning and an end date from a criteria form.
>>I have created the form FrmMakeDayFile with 2 unbound fields
[txtDateFr] and [TxtDateTo]. I simply want to be able to click a
button and have a routine of some sort append records to the table
tblDates with field Ddate inserted starting from txtDateFr and adding
a new record for each date, ending at TxtdateTo. (This data gets used
in a local front-end and is then zapped... but that part's under
control - I just need to quickly seed values to the dayfile table....)
>>I must be having a vague day as something that shoudld so easy is
eluding me... *Can anybody start me off please.
>>thankyou.
Dave
>I might have a command button to initiate the append. *Air code
* * * *Dim datFor As date
* * * *Dim rst As Recordset
* * * *set rst = Currentdb.openrecordset("TableName",dbopendynaset)
* * * *It Not IsNull(Me.FromDate) And Not IsNull(Me.ToDate) then
* * * * * * * *For datFor = Me.FromDate to Me.ToDate
* * * * * * * * * * * *rst.Addnew
* * * * * * * * * * * *rst!TableDateField = datFor
* * * * * * * * * * * *rst.Update
* * * * * * * *Next
* * * *Endif
>Soon is nowhttp://www.youtube.com/watch?v=K2NrIALcNOw-Hide quoted text-
>- Show quoted text -
OK - thankyou Salad!!
Here' the tidied version of your air code... Worked a treat! Thankyou
very much. It's 3:40 am here... time for some zzzzz's. Much
appreciated. Dave.

It appears you are a bit aways from the US. *Australia?

I think you can either go to bed now or get up for the Monday commute.


Private Sub CmdMakeDayFile_Click()
Dim datFor As Date
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("tblDates", dbOpenDynaset)
If Not IsNull(Me.txtFromDate) And Not IsNull(Me.txtToDate) Then
* * For datFor = Me.txtFromDate To Me.txtToDate
* * * * rst.AddNew
* * * * rst!Ddate = datFor
* * * * rst.Update
* * Next
End If
End Sub- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
Yes, I'm in Sydney and thankyou to all for your quick and varied
suggestions. I've tried posting on other help forums before and gone
days without a response, so I really appreciate the way you've all
jumped in and helped.

Now.. I owe I owe... so off to work i go..

Dave
Jun 27 '08 #9

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

Similar topics

2
by: Ryan Wagner | last post by:
I am doing many SQL insert statements to insert records into an oracle database. I need the order of the records, after inserting all records, to be the same as the order I inserted them in. Right...
2
by: P of Dhump | last post by:
Hello, I'm new to asp.net and ado.net so please reply considering that in mind. I'm trying to insert some records which are in a .CSV file but the insert is working double time. i have 744 records...
6
by: Pushpendra Vats | last post by:
Hi , I am trying to insert records into database. I am trying to write the following code. On button1 click event i am inserting five records and after that i am calling the update method of...
1
by: gouse | last post by:
Hello Friends, In a Table I am inserting more than 50,000 Records one by one. It was taking a lot of time . Is it There any good approach/solution for inserting records more than 50,000 one by one...
4
memoman
by: memoman | last post by:
Can any body help me in that program ??? mail me if anybody could reach any -helpfull- thing Write a C++ program that namely insert, delete, and search in a fixed record length file (containing...
3
by: veerapureddy | last post by:
Hai everybody, i like to insert some records into database from html form by entering data.my problem is how can i check , whether a record is available in database about a particular...
13
by: imnewtoaccess | last post by:
Hi, I am getting errors while inserting records in one table from another. These are the structures of two tables : file51tm_new RecordType Text
5
by: dos360 | last post by:
Hello, I have two tables, one is a list of activities, the other a list of participants. I want to insert one record in the activities table and then using its identity column as foreign key, I...
6
by: pompeyoc | last post by:
Hi! We are having problems with an SQL stored proc that uses Global Temporary Tables. The SP creates the GTT as follows: DECLARE GLOBAL TEMPORARY TABLE TEMP_ENTRIES (field1, field2, etc) ON...
7
by: Lebbsy | last post by:
I have a 5-tabbed form that is used to add records in five different tables. The tables are excel-linked. When I press the save button the records goes to different tables but the fields are not...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
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...
0
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,...
0
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...
0
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...

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.