10th March 2006, 08:02 PM
|
Member
|
|
Join Date: Dec 2004
Posts: 172
|
|
Quote:
Originally Posted by PunterPete
Set dbs = CurrentDb
strSQL = "INSERT QUERY FOR ALL DATA HERE" ' eg "SELECT .....;"
Set rst = dbs.OpenRecordset(strSQL)
Do While Not rst.EOF
If rst.Fields(0) >= d1 And rst.Fields(0) <= d2 Then
Write #2, rst.Fields(0).Value;
Write #2, rst.Fields(1).Value;
Write #2, rst.Fields(2).Value;
Write #2, rst.Fields(3).Value;
Write #2, rst.Fields(4).Value;
Write #2, rst.Fields(5).Value;
'etc etc etc
End If
Loop
Close #2
rst.Close
|
Hi!
" rst.Fields(0) >= d1 And rst.Fields(0) <= d2" this could go straight into strSQL like "where the date is >= and date is <= " the date in the database, saves you going through the loop. SQL is at least a hundred times faster than a loop, depending on a few other things of course.
( <= be careful how you define d1 and d2 I would use < d2 because you might double up on the upper date).
cheers
|