473,750 Members | 2,500 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inserting multiple rows based on a Date range

5 New Member
Hi Bytes,

Using a previous question as a base Access 2000 Inserting multiple rows based on a date range.
I also wanted to insert multiple rows into a table according to a date range supplied by a user (eg txtRDateStart & txtRDateEnd). The script was envisaged to be able to also gather a time and text description that would be repeated within each row.

For example:
The user would enter...
Start Date: 13/03/2010
End Date: 17/03/2010
Time: 12:00
Description: "Check Mail"

click 'OK'...
Thereby resulting in 5 new rows added to a table 'tblReminders' into columns RDate, RTime & RDescription such as...

13/03/2010, 12:00, Check mail
14/03/2010, 12:00, Check Mail
15/03/2010, 12:00, Check Mail
16/03/2010, 12:00, Check Mail
17/03/2010, 12:00, Check Mail

Using the code provided by PEB in Access 2000 Inserting multiple rows based on a date range

I ended up with the below that is working however the Date being returnned is always the '30/12/1899'.
I understand this is probably due to the way dates are configured in Access and the use of 'Int' in the below code, so I changed to table's RDate field format from short date to nothing and I seem to be getting a time value returning, e.g. for 13/03/2010 the return is 12:03:21 AM. - when I format this to a 'Short Date I again get '30/12/1899'.
Expand|Select|Wrap|Line Numbers
  1. Dim RepeatEvent
  2.  
  3. For RepeatEvent = Int(CDate(Me!txtRDateStart)) To Int(CDate(Me!txtRDateEnd))
  4.  
  5. DoCmd.RunSQL "INSERT INTO tblReminder (RDescription, RDate, RTime) " & _
  6.              "SELECT Forms![frmReminder_New]!txtRDescription AS Expr1," & _
  7.              Format$(RepeatEvent, "dd/mm/yyyy") & _
  8.              ", [Forms]![frmReminder_New]![txtRTime] AS Expr3;"
  9.  
  10. Next RepeatEvent
Any help would be greatly appreciated.
Mar 13 '10 #1
3 5024
NeoPa
32,571 Recognized Expert Moderator MVP
Your problem is a lack of delimiters around your date data. It is literal data (rather than a reference) so must be delimited if string or Date/Time (See Literal DateTimes and Their Delimiters (#) and Quotes (') and Double-Quotes (") - Where and When to use them).

It's not clear from this, what type of field [RDate] is in tblReminder. I would guess it's actually a string, but it may conceivably be a Date/Time.

If it's a string then your lines #7 through #9 should be :
Expand|Select|Wrap|Line Numbers
  1.              "SELECT Forms![frmReminder_New]!txtRDescription AS Expr1,'" & _
  2.              Format$(RepeatEvent, "dd/mm/yyyy") & _
  3.              "', [Forms]![frmReminder_New]![txtRTime] AS Expr3;"
If it's a date then they should be :
Expand|Select|Wrap|Line Numbers
  1.              "SELECT Forms![frmReminder_New]!txtRDescription AS Expr1,#" & _
  2.              Format$(RepeatEvent, "m/d/yyyy") & _
  3.              "#, [Forms]![frmReminder_New]![txtRTime] AS Expr3;"
NB. It doesn't matter where you're from. m/d/yyyy is always correct for SQL literal dates.
Mar 13 '10 #2
Vinda
5 New Member
NeoPa that has worked like a charm, thankyou so very much.
My field within tblReminder is a date field and so inserting the '#'s was spot on.
Thanks again, I very much appreciate your time.
Cheers,
Vince
Mar 14 '10 #3
NeoPa
32,571 Recognized Expert Moderator MVP
Happy to help Vince :)
Mar 15 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

20
2592
by: WindAndWaves | last post by:
Hi Gurus I was wondering if you can send me in the right direction: I have a table with about 300 rows. I want to make all of them invisible and when a user enters a code in a form then make selected ones visible. At the moment, I am doing it as follows: www.corstorphinehouse.com/d/avail.html
16
3851
by: Tim Davidge | last post by:
Hi folks, been a while since I have posted a plea for help and I think I have forgotten everything I learnt from the helpful contributors to this newsgroup, that said however : I'm trying to insert a range of dates for the past say two years into the first column of say a two column table. I've been trying to use 'current date' and working backwards from there but for the life of me I cannot get the syntax right. I can produce a single...
0
2073
by: B | last post by:
Using Access2000, the sample code below is what I have been modifying and working on since the past week and I could not get it to work properly. What I wanted to accomplish: 1) read from a recordset and export to Excel 2) Excel is populated based from an ID (may possible be one or multiple) and renames the worksheet based from the ID 3) the code also format the fields The sample database may be downloaded at:
7
3391
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always either AND or OR but never mixed together. We can use Northwind database for my question, it is very similar to the structure of the problem on the database I am working on. IF(SELECT OBJECT_ID('REPORT')) IS NOT NULL DROP TABLE REPORT_SELECTION
15
2909
by: Jaraba | last post by:
I am working in a project that I need to parse an arrayt an select records based upon the values parsed. I used the functions developed by Knut Stolze in his article 'Parsing Strings'. I am particulary having problems inserting records using a function. I am attaching the code for your review. Please, help. =================================--Function 1--====================================
4
4978
by: Joanie | last post by:
I have a form that records dates of unavailability for a worker. Based on what is entered in the simple table behind the form, many calculations take place to create employee "load" balance. Each day needs to be inserted as a separate row on the table. Right now the users enter each date as a separate row. They want to just be able to enter a range. How do I add the multiple rows from the date range entered on the form AND exclude weekends?
2
13556
by: chrisale | last post by:
Hi All, I've been racking my brain trying to figure out some sort of Sub-Select mySQL statement that will create a result with multiple rows of averaged values over a years time. What I have is weather data. There is a new record every 5 minutes, every day. So. What I want to do with one SQL statement is figure out the Average of those 5 minute records over each day, for every day of the year.
0
3663
by: c0dergirl | last post by:
This c# program allows you to select multiple items from a listbox. For each selected item, a worksheet is created in the workbook with some information. Right now I create a chart that plots some information from one of the sheets. What I want to do is have a line on the graph for every sheet. I assume I use multiple datasources to do this, but I don't know how to use the SeriesCollection class to accomplish this. Here's my code....
0
3477
by: acarrazco | last post by:
Hello, I am totaly new to VBA and I'm trying to modify a macro that was given to me but it doesn't seem to be working. I'm trying to extract data from three excel spreadsheets, put it into a combined one which creates a pivot table and sorts it into different fromats. Here is the code, can any body help? Sub Update_Land_Actuals() On Error Resume Next If InputBox("Enter password to continue", "Centex Homes") <> "***" Then Exit Sub...
1
4419
by: evenlater | last post by:
I have an Excel workbook that I'm programming from Access. The rows in the workbook vary in height. So let's say row 8 is taller than the rows above it. If I *manually* insert 2 new rows at the top, row 8 becomes row 10 and row 10 is now the taller row. That’s the way I want it to be. But when I insert lines using VBA code, row 8 remains taller and row 10 is shorter. That messes up the way my data is displayed. Is there a way to get...
0
8839
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
9584
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9398
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
9257
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8265
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...
0
4716
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
4894
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2227
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.