B
burton1986
Hi All, I have a question and would be welcome any help/suggestions.
I have a table that is in the below format
RA Start Days Date
James 31-07-09 2
Burton 01-08-09 2
I need to create new records in a different table to show everyday after and
including the startdate based on the days figure. For example James would be
as below.
Ra Start
James 31-07-09
James 01-08-09
James 02-08-09
I have code that does this already but it is taking about 5 secs per "day"
which when working with 500K records in the first table it will take forever
to complete considering the number of "days".
My Code is below can you please let me know if you can suggest a way to speed
it up?
DoCmd.SetWarnings False
Dim Rs As Recordset
Dim Num As Integer
Dim CurrentDate As Date
Dim I As Integer
Set Rs = CurrentDb.OpenRecordset("QryRS")
Rs.MoveFirst
Do Until Rs.EOF
Num = Rs("Days")
CurrentDate = Format(Rs("Start"), "DD/MM/YYYY")
[Forms]![Form1]![RA] = Rs("Ra")
For I = 1 To Num + 1
CurrentDate = Format(CurrentDate, "DD/MM/YYYY")
DoCmd.RunSQL "INSERT INTO TblDaysApp ( RA, Start, 1 ) SELECT QryRS.RA, QryRS.
Start, Cdate(Format('" & Format(CurrentDate, "DD/MM/YYYY") & "')) AS Expr1
FROM QryRS WHERE (((QryRS.RA)='" & [Forms]![Form1]![RA] & "'));"
CurrentDate = Format(DateAdd("D", 1, CurrentDate), "DD/MM/YYYY")
Next I
Rs.MoveNext
Loop
Thanks a lot for your time.
I have a table that is in the below format
RA Start Days Date
James 31-07-09 2
Burton 01-08-09 2
I need to create new records in a different table to show everyday after and
including the startdate based on the days figure. For example James would be
as below.
Ra Start
James 31-07-09
James 01-08-09
James 02-08-09
I have code that does this already but it is taking about 5 secs per "day"
which when working with 500K records in the first table it will take forever
to complete considering the number of "days".
My Code is below can you please let me know if you can suggest a way to speed
it up?
DoCmd.SetWarnings False
Dim Rs As Recordset
Dim Num As Integer
Dim CurrentDate As Date
Dim I As Integer
Set Rs = CurrentDb.OpenRecordset("QryRS")
Rs.MoveFirst
Do Until Rs.EOF
Num = Rs("Days")
CurrentDate = Format(Rs("Start"), "DD/MM/YYYY")
[Forms]![Form1]![RA] = Rs("Ra")
For I = 1 To Num + 1
CurrentDate = Format(CurrentDate, "DD/MM/YYYY")
DoCmd.RunSQL "INSERT INTO TblDaysApp ( RA, Start, 1 ) SELECT QryRS.RA, QryRS.
Start, Cdate(Format('" & Format(CurrentDate, "DD/MM/YYYY") & "')) AS Expr1
FROM QryRS WHERE (((QryRS.RA)='" & [Forms]![Form1]![RA] & "'));"
CurrentDate = Format(DateAdd("D", 1, CurrentDate), "DD/MM/YYYY")
Next I
Rs.MoveNext
Loop
Thanks a lot for your time.