extracting dir names from path to a table. from prev. Post..New Tw

G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top