Table population

J

john

Hi,

more help please.

Is there a way to enable access to automatically populate a table with a
series of files / objects located on a hard disk?

cheers
 
N

Nikos Yannacopoulos

John,

The answer is generally Yes. Provide more details, anmd you might even be
told How!

Nikos
 
J

john

Hi Nikos,

I would like to automatically "grab" or copy a number of files / pictures
on my hard drive and to place them in a table to support inclusion in a
report / form.

I have tried to achieve the inclusion of such by manually "dragging and
dropping" the objects into OLE formatted tables but this will be overly time
consuming within my current project constraints

cheers
 
N

Nikos Yannacopoulos

John,

You got me there... I don't have much experience with OLE objects, but from
what I've seen in the NGs, I think the general suggestion is to just store
references to the files on your disk, instead of embedding the objects
themselves. Maybe you should seek more advice on this.

For what it's worth, here's some sample code that will scan all the .jpg
files in a particular folder and put their names in an (existing) table
called tblFiles, just as long as the first field is type Text (and big
enough to hold long names! better make it 256):

Sub filenames_to_table()
Dim fldr, fls, fl
Dim db As DAO.Database
Dim rst As DAO.Recordset

Set fs = CreateObject("Scripting.FileSystemObject")
Set fldr = fs.GetFolder("C:\FolderName\")
Set fls = fldr.Files
Set db = CurrentDb()
Set rst = db.OpenRecordset("tblFiles")
On Error Resume Next
For Each fl In fls
If Right(fl.Name, 4) = ".jpg" Then
rst.AddNew
rst.Fields(0) = fl.Name
rst.Update
End If
Next fl
On Error GoTo 0
rst.Close
End Sub

HTH,
Nikos
 
Z

Zadok @ Port of Seattle

Nikos,
I used your code and it worked locally, but when I try to get a list from a
network drive nothing happens. Am I missing something?

Thanks,
Zadok
 

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