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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I import file names into a table? 7

Status
Not open for further replies.

Hanss

Technical User
Feb 15, 2001
85
CH
I would like to have vb search a directory and import all the file names into an access table. Does anyone have any ideas how this can be done?

Hanss
Zurich

 
Hi, this has been very helpful but I am having some trouble in the form of unconventional file names. The sql bombs when I run into an apostrophe (Dave's File.xls for example. There are files with Pound # signs too.)

Can the sql be modified to account for file names like this?

Alternatively, the only files I really need to retrieve are .pdf files and these are named correctly. Can the code from SharonNiles last post be modified to write only .pdf files to a table?

Thanks, Dan


DoCmd.RunSQL ("Insert Into TblFileList Values('" & objFiles.Name & "','" & objFolder.Path & "'," & Round(objFiles.Size / 1024, 2) & ");")
 
DoCmd.RunSQL ("Insert Into TblFileList Values('" & [highlight]Replace([/highlight]objFiles.Name[highlight], "'", "''")[/highlight] & "','" & [highlight]Replace([/highlight]objFolder.Path[highlight], "'", "''")[/highlight] & "'," & Round(objFiles.Size / 1024, 2) & ");")


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
If UCase(Right(objFiles.Name, 4)) = ".PDF" Then
DoCmd.RunSQL ("Insert Into TblFileList Values('" _
& Replace(objFiles.Name, "'", "''") & "','" _
& Replace(objFolder.Path, "'", "''") & "'," _
& Round(objFiles.Size / 1024, 2) & ");")
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks PHV - Just read all the files into a table - all 10256 of them.

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top