Results 1 to 5 of 5

Thread: [RESOLVED] SQL Query Split Record?

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2008
    Posts
    101

    Resolved [RESOLVED] SQL Query Split Record?

    Firsty Apologies if this is in the incorrect section.

    I have a small database created in MS Access and Im trying to write a query that transfers data from one table to another after researching the topic I have come up with the following SQL Statement:

    Code:
    INSERT INTO tblTest (Code, Product, DaysCover, MaxCover, InStock)
    SELECT Code, Product, DaysCover, MaxCover, InStock FROM tblProducts
    WHERE IncludeInPlanning=True AND InStock=True;
    This statement works perfectly and fills the tblTest with the correct details passed from tblProducts.

    My question is I need to have a record for each day for the paticular Product, I Would like to store a Date into tblTest, The date would be required for everyday including week ends (7 Days). The Date does not come from the Products table but can be specified by the user (Start Date and End Date)

    so.. each Product in tblTest will have as many records as the user specifies associated with it (one for each day of the week)

    Is there any simple SQL query that do this easily?

    Thanks in advance

    edit: As mentioned before the user can specify the start and end date so im planning on writing a front end for the database possibly in vb.net, I will probably use two of the DateTimePicker to allow the user to select the start/end dates. after thinking about this a bit more would a loop be needed so that for each date specified, insert into the test table??

    I have found some sample code from this site that can grab the value of two specified dates and store within a listbox here is the code:

    Code:
    ListBox1.Items.Clear()
    
            Dim StartDate As DateTime = DateTimePicker1.Value.Date
            Dim EndDate As DateTime = DateTimePicker2.Value.Date
    
    
            ListBox1.Items.Add(StartDate)
    
            Dim currentDate As Date = StartDate
            Do
    
                currentDate = currentDate.AddDays(1)
                ListBox1.Items.Add(currentDate)
            Loop Until currentDate >= EndDate
    Last edited by enex; Feb 15th, 2010 at 11:16 AM. Reason: updated with more info

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width