10th March 2006, 07:45 PM
|
Member
|
|
Join Date: Jan 1970
Location: NSW
Posts: 53
|
|
MS Access
Try this - Very simple text file creation.
Insert a button on a form and place the following code under "On Click":
Note I have written this very quickly and haven't tested it and you will need to insert your own query and make your own formula for d1 & d2.
Dim dbs As Database
Dim rst, horserst As Recordset
Dim strSQL, filename As String
Dim d1, d2 As Date
Dim i
For i = 1 To 38 ' or however many files you need
'd1 = Calculation to get lower date using i
'd2 = Calculation to get upper date using i
filename = "Info" & i & ".txt"
Open "C:\DIR\" & filename For Output As #1
Set dbs = CurrentDb
strSQL = "INSERT QUERY FOR ALL DATA HERE" ' eg "SELECT .....;"
Set rst = dbs.OpenRecordset(strSQL)
rst.MoveFirst
i = 0
Write #2, "COLTILE1"; "COLTITLE2"; "COLTITLE3"; et; etc
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
Next i
__________________
Regards,
Pete
|