psulions83
Board Regular
- Joined
- Nov 16, 2015
- Messages
- 127
Hi,
There are lots of topics on writing to txt files and userforms but I am not sure if I follow how to apply there. I have the below query that I would love to have a log file within Access table or have it output a text file to a folder. The debug print immediate window out put is sort of what I am looking for. Is this possible?
There are lots of topics on writing to txt files and userforms but I am not sure if I follow how to apply there. I have the below query that I would love to have a log file within Access table or have it output a text file to a folder. The debug print immediate window out put is sort of what I am looking for. Is this possible?
Code:
Public Function loopTable()
Dim strSQL As String
Dim rs As DAO.Recordset
Dim SrcFilePath As String, HaveFile As Boolean
Dim ImprtSpec, TblNm, FileNm As String
Debug.Print "File Load procedure Started at " & Now()
strSQL = "SELECT * FROM Tbl_Data_Load"
Set rs = CurrentDb.OpenRecordset(strSQL)
If Not rs.BOF And Not rs.EOF Then
rs.MoveFirst
While (Not rs.EOF)
ImprtSpec = rs.Fields("ImportSpecNm")
TblNm = rs.Fields("TableName")
FileNm = rs.Fields("FileName")
SrcFilePath = Application.CurrentProject.Path & "" & FileNm
Debug.Print rs.Fields("FileName")
If Dir(SrcFilePath) = "" Then
Debug.Print "No " & rs.Fields("FileName") & " Exists"
Else
Debug.Print rs.Fields("FileName") & " File Now Loaded"
DoCmd.TransferText acImportDelim, ImprtSpec, TblNm, Application.CurrentProject.Path & "" & FileNm, True
End If
rs.MoveNext
Wend
End If
rs.Close
Set rs = Nothing
Debug.Print "File Loaded - " & Now()
End Function
Last edited: