You are on page 1of 1

Private Sub Form_Timer()

' do a periodic backup of records


Dim stFile As String
Dim rs As DAO.Recordset2
Dim fld As DAO.Field2
Dim stData As String

' show status


Me.lblWait.Visible = True
DoEvents

' open the file name - latest data always available


stFile = CurrentProject.Path & “\CustomerBackup.txt”
Open stFile For Output As #1

' get the data


Set rs = CurrentDb().OpenRecordset(“Customers”)
While (Not rs.EOF)
' loop through fields and build the data string
For Each fld In rs.Fields
If (Not fld.IsComplex) Then
stData = stData & fld.Value & “|”
End If
Next

' print
Print #1, Left(stData, Len(stData) - 1)
rs.MoveNext
DoEvents
Wend

' cleanup
rs.Close
Set rs = Nothing
Set fld = Nothing

Close #1

' hide status


Me.lblWait.Visible = False
End Sub

You might also like