Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[COLOR=green]''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'' References:
'' MS DAO 3.6
'' MS Scripting Runtime
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''[/color]
Sub ReadTxtImport01()
On Error GoTo Err_ReadTxtImport01
Dim fs As FileSystemObject, f As File, ts As TextStream [COLOR=green]'' Variables for FileSystemObject
'Dim rst As DAO.Recordset[/color]
Dim strFile As String
Dim strLine As String
Dim strName As String, strDOB As String
strFile = "C:\TextFiles\sample04.txt"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(strFile)
Set ts = f.OpenAsTextStream(1, -2)
[COLOR=green]'Set rst = CurrentDb.OpenRecordset("tblTextFiles")[/color]
Do While ts.AtEndOfStream <> True
strLine = ts.ReadLine
strName = Mid(strLine, InStr(strLine, "Name: ") + 5, InStr(strLine, "DOB: ") - 6)
strDOB = Mid(strLine, InStr(strLine, "DOB: ") + 4)
Debug.Print strName, strDOB
[COLOR=green]' With rst
'
' .AddNew
'
' !Name = strName ''Text field
' !DOB = strDOB ''Text field
'
' .Update
'
' End With[/color]
'
Loop
Exit_ReadTxtImport01:
ts.Close
[COLOR=green]'rst.Close
'Set rst = Nothing[/color]
Set ts = Nothing
Set f = Nothing
Set fs = Nothing
Exit Sub
Err_ReadTxtImport01:
Debug.Print Err.Number, Err.Description
End Sub