Multiple Input

T

The Worker Bee

I am creating a database that is only to hold information
of the image files of a hard drive. How can i bulk input
the files, or input them by folder so that I don't have
to input every records fields seperately. Some fields are
the image itself; the filesize; the filename (as a
hyperlink) and the type of file. Is there anything I can
do. And I don't want to delete the files as they are
being transferred!

Charlie
 
J

John Nurick

Hi Bee,

If you're keeping your data in an mdb file it's not a good idea to store
the image data in the database: instead, leave it in the folders and
just store the paths, filenames, etc. There's a PictureMgr sample
database at http://www.datastrat.com/DataStrat2.html which shows the
techniques.

To get the file information from the drive, there are several ways to
go. I'd use the VBScript FileSystemObject object, which is in the
Microsoft Scripting Runtime library. This lets you do something like
this untested air code:

Dim dbD As DAO.Database
Dim rsR As DAO.Recordset
Dim oFS As Scripting.FileSystemObject
Dim oF As Scripting.Folder
Dim oS As Scripting.File
Dim strType As String
Dim strFolder As String
Dim lngSize As Long

strFolder = "C:\Folder\Subfolder"
strType = "jpg"

Set dbD = CurrentDB()
Set rsR = dbD.OpenRecordset("MyTable")
Set oFS = CreateObject(strFolder)
Set oF = oFS.GetFolder("C:\Folder\Subfolder")

If oF.Files.Count > 0 Then
For Each oS In oF.Files
If Right(oS.Name, Len(strType)) = strType Then
With rsR
.AddNew
.Fields("FileName").Value = oS.Name
.Fields("FileType").Value = oS.Type
.Fields("FileSize").Value = oS.Len
.Update
End If
Next
End If
rsR.Close
Set rsR = Nothing
Set dbD = Nothing
Set oS = Nothing
Set oF = Nothing
Set oFS = Nothing
 

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