Script To attach files to records

  • Thread starter Thread starter Terrence B. via AccessMonster.com
  • Start date Start date
T

Terrence B. via AccessMonster.com

Does any have a script to attach files on my network to specific records in
an Access database? The file names are in this format P1_0001.txt and the
record it needs to attached to is 1.0001; the next file name would be P1_0002
and the corresponding database record is 1.0002, etc.......

I have 2300 files that I need to upload into Access in it's corresponding
record. Does anyone have a script that can do this??

Thanks,
Terrence
 
Actually, what I need is a way to attach the hyperlink to the file location,
NOT the file. There are 2300 files that I need hyperlinks attached one to
each record.

Does anyone know how to do this??

Thanks,
Terrence
 
I'll assume that the identifying values 1.0001, 1.0002 etc. are stored
in a text field named ID. (Text, because of the complications that can
arise when using floating point values as keys.)

You can populate the hyperlink field by using an expression like this in
an update query, substituting the actual path to the folder containing
the text files:

"D:\Folder\Sub folder\P" & Replace([ID], ".", "_") & ".txt"

Or - if the relationship between the ID value and the filename is
permanent - you can omit the hyperlink field and use a similar
expression to generate the path whenever needed. E.g. in a
commandbutton's Click event procedure,

Application.FollowHyperlink "D:\Folder\Sub folder\P" _
& Replace([ID], ".", "_") & ".txt"
 
Back
Top