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

help on adding image file pathways to a table 1

Status
Not open for further replies.

GIJoeFigure

Technical User
Jun 16, 2004
27
0
0
US
Hello all,
I am new to this site and Access, and I was just wondering if anyone knows the best way to output into a table certain drive pathways for image files, for example:

c:\programs\images\fun.img

I also saw this solution on a different site this command but do not understand how to implement it:

CurrentDB.Execute ("Insert into xx select * from yy"), dbFailOnEror

I made a table to extract the pathways to. It is important to have the pathways because I have a module that can take these pathways and extract header information directly, so I just need to find the best way to list all the possible files in my table. Eventually I will have to do multiple folders, and I was thinking about cloning a sample table to make new tables. I also wonder if this is the easiest way to make additional tables, one for each drive folder (since I have thousands of images to go through)?

Thanks Alot in advance
 
Well welcome to tek-tips Joe.

I'm not exactly sure what you are after but before you leap on to multiple tables think carefully about database structure and don't allow your database design to be driven by a simple hard drive file structure.

do you have these images in a list somewhere or are you looking them up and gathering them on the fly ?


I have recently written some code that starts at a given folder level and searches all sub folders for files of a specific type, then creates the folder\subfolder\file structure on a Treeview Control on an Access form

You could adapt that to write to a table instead of to the TreeView control if thats what you need






G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Thanks LittleSmudge for your fast reply!

I am trying to gather the images' paths from a bunch of designated folders on our network drives, so I know the folders that need to be searched. I don't have an image list, but your treeview form idea in your code sounds very useful. I would appreciate it if you could tell me a little more about it, such as if it requires any premade Access tables or other data, and also can you post your code or give me an idea of how it goes? I would really appreciate it and my division that I'm interning for would also.

Thank you for your time.
 

Code:
Call PopulateTree(mconstrRoot & "\" & cboSelectReport)
mconstrRoot is the \\Sever\path\folder string
cboSelectReport provides the final level folder

Code:
Private Sub PopulateTree(SourcePath As String)

Dim fso As Object
Dim objDisplay As Object
Dim objNode As Node
Dim MyFolder As Folder
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(SourcePath) Then
    ' First empty out the CRDisplay of any old data
    CRDisplay.Nodes.Clear
    CRDisplay.Requery
    Set MyFolder = fso.getfolder(SourcePath)
    ' Now populate with new data
    Call GetSnapshots(MyFolder)
Else
    MsgBox "There is a error in the definition of the path I am expected to look in" & vbLf _
         & "The folder path " & SourcePath & vbLf _
         & "does not exist", , "Who's moved it ?"
End If
End Sub

Private Sub GetSnapshots(fld As Folder, Optional hld As Folder = Null)
On Error Resume Next
Dim subfld As Folder
Dim fil As file
Dim nodNew As Node
'MsgBox fld.Name
If hld Is Nothing Then ' This is FIRST call
    Set nodNew = CRDisplay.Nodes.Add(, , fld.Name, fld.Name)
    nodNew.Expanded = True
Else                   ' This is a recursive self call
    CRDisplay.Nodes.Add hld.Name, tvwChild, fld.Name, fld.Name
    DoCmd.Echo True, "Researching the contents of folder " _
                    & MID(fld, Len(mconstrRoot) + 1)
End If
For Each subfld In fld.subfolders
    Call GetSnapshots(subfld, fld)    ' Recursive call
Next
For Each fil In fld.Files
'    MsgBox "fil.path = " & fil.path & vbLf _
          & "fil.name = " & fil.Name
'    MsgBox fil.Type, , "File Type"
    If fil.Type = "SnapShot File" _
    Or fil.Type = "Microsoft Excel Worksheet" Then
        CRDisplay.Nodes.Add fld.Name, tvwChild, fil.path, fil.Name
    End If
Next
End Sub

CRDisplay is the name of the TreeView control itself
You need to change the fil.Type line to match the image types you need.



'ope-that-'elps.

Also, take a look at the link the kramerica posted. There may well be some things to help you in there.




G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
You need to include the

Microsoft Windows common controls 6.0

Usually in Win\System32\ as file MSCOMCTL.ocx

into your references list if it doesn't do so automatically in order for the above code to compile.



'ope-that-'elps.



G LS
spsinkNOJUNK@yahoo.co.uk
Remove the NOJUNK to use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top