B
BrianPaul
here is the function that was given to me from previouse post.
Function LocateFile(strFileName As String)
Dim vItem As Variant
Dim db As DAO.Database
Set db = CurrentDb
With Application.FileSearch
.FileName = strFileName
.LookIn = "N:\Databases\Tech manuals"
.SearchSubFolders = True
.Execute
For Each vItem In .FoundFiles
db.Execute _
"INSERT INTO TBook (BookName) " & _
"VALUES(" & Chr(34) & vItem & Chr(34) & ")", _
dbFailOnError
Next vItem
End With
Set db = Nothing
End Function
Works great, however will not list files in the table that has a .zip file
extension or the folder. for example: I have a file that wont import the
path and the filename N:\Databases\Tech manuals\AutoRepair\AutoRepair.zip
Instead of importing filenames, can I just import the folders. then I can
use the split function. Note on Split Function using Access 2003 in
yesterdays post.
Function GetSecondElement(InputValue As String) As String
GetSecondElement = Split(InputValue, "\")(2)
End Function
Only thing that did work correctly....Great Function!
I can change this function so it returns the value in a query Auto Repair
from the above example by changing the (2) to a (3) etc.
Thanks guys
Function LocateFile(strFileName As String)
Dim vItem As Variant
Dim db As DAO.Database
Set db = CurrentDb
With Application.FileSearch
.FileName = strFileName
.LookIn = "N:\Databases\Tech manuals"
.SearchSubFolders = True
.Execute
For Each vItem In .FoundFiles
db.Execute _
"INSERT INTO TBook (BookName) " & _
"VALUES(" & Chr(34) & vItem & Chr(34) & ")", _
dbFailOnError
Next vItem
End With
Set db = Nothing
End Function
Works great, however will not list files in the table that has a .zip file
extension or the folder. for example: I have a file that wont import the
path and the filename N:\Databases\Tech manuals\AutoRepair\AutoRepair.zip
Instead of importing filenames, can I just import the folders. then I can
use the split function. Note on Split Function using Access 2003 in
yesterdays post.
Function GetSecondElement(InputValue As String) As String
GetSecondElement = Split(InputValue, "\")(2)
End Function
Only thing that did work correctly....Great Function!
I can change this function so it returns the value in a query Auto Repair
from the above example by changing the (2) to a (3) etc.
Thanks guys