Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file listing

Status
Not open for further replies.

swtrader

IS-IT--Management
Dec 23, 2004
182
US
I am using Allen Browne's code to get file names.
/ Thanks, Allen

I would appreciate help in editing it so that the full path is in one field. Also, although I can probably figure it out eventually, it would be good if someone can write the code that will truncate the file name to the last 5 characters before the file type -- in other words, each file will have a 5 character file 'number' at the end -- such as ' 51003.pdf '. I need the 51003 in a separate field so that I end up with a table:

51003 | C:\Data\ABC.Lease.20110902.51003.pdf

here's the snippet I need help with.....

Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant
Dim strSql As String

'Add the files to the folder.
strFolder = TrailingSlash(strFolder)
strTemp = dir(strFolder & strFileSpec)
gCount = 0

Do While strTemp <> vbNullString
gCount = gCount + 1
SysCmd acSysCmdSetStatus, gCount
strSql = "INSERT INTO myFiles " _
& " (FName, FPath) " _
& " SELECT """ & strTemp & """" _
& ", """ & strFolder & """;"
CurrentDb.Execute strSql
colDirList.Add strFolder & strTemp
strTemp = dir
Loop

Thank you!!
 
Solved. I toyed with and wrote some clunky code but it works.

Thanks for looking.

swt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top