I have received alot of help from this site and I am grateful. My problem is that I was able to get the first part of code to work. I tested it via the immediate window. I received the compile error "expected expression" when I tested for function InputFile.
?InputFile(Opti onal strPath As String)
"expected expression"
?InputFile()
"expected function or variable"
Below is the code that I was given-with slight modification
?InputFile(Opti onal strPath As String)
"expected expression"
?InputFile()
"expected function or variable"
Below is the code that I was given-with slight modification
Code:
Public Function readFile(Optional strPath As String) As String
'Create a filesystemobject
Dim fso As Object
Set fso = CreateObject("scripting.filesystemobject")
'Open file for reading
strPath = "C:\Users\jeffrey.musgray\Desktop\TcossDocument.txt"
readFile = fso.OpenTextFile(strPath, 1).ReadAll
'Cleanup
Set fso = Nothing
End Function
Public Sub InputFile(Optional strPath As String)
Dim strContent As String
strContent = readFile(strPath)
Dim rsDao As DAO.Recordset
Set rsDao = CurrentDb.OpenRecordset("SELECT * FROM tblTSR", dbOpenDynaset)
rsDao.AddNew
With rsDao
![TSR Number] = getValue(strContent, 101, 103)
![Type Action] = getValue(strContent, 103, 104)
![TYPE OF SERVICE] = getValue(strContent, 104, 105)
![Requesting Activity's Requirement Number] = getValue(strContent, 514)
End With
rsDao.Update
Set rsDao = Nothing
End Sub
Comment