Hi Si,
I have tried what you have suggested but it throws out an SQL error. Is this because im inserting from a select statement??, how can I pass values from elsewhere within the same statement? as mentioned the Date does not come from the table but is user specified.
here is my code so far:
Code:'Allow the user to select start/end date from DateTimePickers Dim StartDate As DateTime = dtpStartDate.Value.Date Dim EndDate As DateTime = dtpEndDate.Value.Date Dim i As Integer Dim NumberOfDays As Integer 'Calculate How many times the record must be added in the for loop NumberOfDays = EndDate.DayOfYear - StartDate.DayOfYear If MsgBox("You are about to insert into the table are you sure you wish to do this?", MsgBoxStyle.YesNo, "Insert INTO") = MsgBoxResult.Yes Then For i = 1 To NumberOfDays Dim SQL As String SQL = ("INSERT INTO tblTest (Code, Product, DaysCover, MaxDaysCover, InStock) SELECT Code, Product, DaysCover, MaxDaysCover, InStock FROM tblProducts WHERE IncludeInPlanning=True AND InStock=True") Next End If
edit: actually after trying again its working.. cheers si!




Reply With Quote
