Create a field with filenames

  • Thread starter Thread starter OveB
  • Start date Start date
O

OveB

Hi,
I have a simple db with some 8000 records and an external folder with
filenames. I wish to get these names into a Pathfield in the main table so
that for each Record# the appropriate filename is fed in the new Pathfileld.
The files are images with names like xyz????.jpg where ???? i the same as
the Record#. Some records have no corresponding image. How to get this? I
would appreciate a detailded answer as my experience with Access is little.
Ove
 
Hi,

This is a bit of code I use to populate a table with PDF
files found within a directory. You can probably adapt
this to find your jpgs.


With Application.FileSearch
.LookIn = "\\dmcs1\data\health\pdf\" 'path to search
.SearchSubFolders = False
.FileName = "*.pdf" 'file type to look for
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For I = 1 To .FoundFiles.Count
fname = .FoundFiles(I)
rsPDF_Report.AddNew
rsPDF_Report![PDF_Name] = fname
rsPDF_Report.Update
Next I
Else
MsgBox "There were no files found."
End If
End With
DoCmd.Close acForm, "patience"
Set rsPDF_Report = Nothing


If I remember correctly parts of this were adapted from
some stuff in the Access help.

HTH

Terry
 
Back
Top