I am string to get read a string value from right to left up to a certain character. I can't seem to get it to work. Does anybody know what i may be doing incorrect?
Here is some of the code:
strTable = InputBox("What table do you want to import the file to?", "Professional File Load")
If strTable = "" Then
MsgBox "The Table name must be enter.", vbInformation, "Table Error"
Exit Function
End If
Set fs = Application.FileSearch
With fs
' Get the folder.
.LookIn = strImportFolder
.FileName = "*.csv"
If .Execute() > 0 Then
For i = 1 To .foundfiles.Count
DoCmd.TransferText acImportDelim, "HistoricalClaimDataProf", strTable, .foundfiles(i)
' If error Then
' module.routine
' Else
strFileLocation = .foundfiles(i)
strFileLocation.ReadingOrder = 2
'This is where my error is occuring
intCharacterValue = InStr(strFileLocation, "\")
strFilename = Right(strFileLocation, intCharacterValue)
sql = "Update " & strTable & " " _
& "SET " & strTable & ".FileName = '" & strFilename & "'" _
& "WHERE (((" & strTable & ".filename) Is Null));"
DoCmd.RunSQL sql
Next i
Else
MsgBox "There were no files found."
End If
End With
strImportResub = foundfiles
End Function
Thanks for any help that you may be able to give.
James
Here is some of the code:
strTable = InputBox("What table do you want to import the file to?", "Professional File Load")
If strTable = "" Then
MsgBox "The Table name must be enter.", vbInformation, "Table Error"
Exit Function
End If
Set fs = Application.FileSearch
With fs
' Get the folder.
.LookIn = strImportFolder
.FileName = "*.csv"
If .Execute() > 0 Then
For i = 1 To .foundfiles.Count
DoCmd.TransferText acImportDelim, "HistoricalClaimDataProf", strTable, .foundfiles(i)
' If error Then
' module.routine
' Else
strFileLocation = .foundfiles(i)
strFileLocation.ReadingOrder = 2
'This is where my error is occuring
intCharacterValue = InStr(strFileLocation, "\")
strFilename = Right(strFileLocation, intCharacterValue)
sql = "Update " & strTable & " " _
& "SET " & strTable & ".FileName = '" & strFilename & "'" _
& "WHERE (((" & strTable & ".filename) Is Null));"
DoCmd.RunSQL sql
Next i
Else
MsgBox "There were no files found."
End If
End With
strImportResub = foundfiles
End Function
Thanks for any help that you may be able to give.
James
Last edited: