Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2005
    Posts
    21

    Unanswered: VBA coding pictures in various subfolders

    I have 23,106 .jpg pictures stored in C:\PICS. In the folder PICS are about 52 subfolders of pictures carrying anywhere around 2 to 100's of pictures. These subfolders have to stay because they name the set of pictures. I develop databases in Filemaker pro and did not have a problem finding a script that does this for me.
    But in ACCESS i am lost. There are programs that say they do it but do not get around the subfolders. Each picture is indentifed by a number. So in my databse I am able to link all my data to these pictures by linking them to my field _id.
    I am hoping there is a way to do it in ACCESS with VBA. Hope someone can help. Thank you.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    im not to certain what your problem is?
    are you saying you need a mechanism to scan the directories to find the files?
    what I'd suggest you should be doing is storing the URL to the image inside the db

    if you want to do a file discovery then its not too hard to do that

    you could use the File Scripting object
    you use the windows DLL's to iterate through directories
    heck you could even do this the old school method and create a file from a piped DIR command, then re process the file inside access
    dir /start/path/*.jpg > MyPhotos.txt
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Dec 2005
    Posts
    21
    I need it to be done automatically. So when a person clicks on page to look at that picture it is already there. In Filemaker pro I am able to embed them as texts so they are always there. But everything I read about access tells you not to embed them. So I am not sure how to link them by ID number where they are always linked to the right page. I will read up on the suggestions you gave. I am lost. Thank you though.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Sorry still don't have a clue what you mean by embedding
    you can store images inside a DB, but in my books its not a smart call. that doesn't matter whether you use filemaker, access, sqllite or a server product. however if you decide its soemthign you feel happy with then finestore images inside Access as a blob or embedded OLE object.

    if you wan to do file discovery and create a row if not in the db then you need to process the a directory structure looking for files with the right extensions
    that will include directories and the JPG or JPEG or whatever actual file extensions.

    have look at MP3 scanners and see if you can findone in Access
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,418
    Provided Answers: 7
    what i would is add a new feild to the database which would hold the path of the file

    them in the form add a picture object and do a loadpicture() to that object useing the ID and the New Feild to display the picture
    Last edited by myle; 06-03-13 at 09:34. Reason: spelling
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  6. #6
    Join Date
    Dec 2005
    Posts
    21

    Red face Linking to external images

    Here is what I did. Found it on another site. But not working. But not getting errors now.

    Field name: Photos
    Data type: text

    Went to the form:
    Added a bound Object frame
    Then went to the control source and put in:
    = C:\Photos\" & [Photos]

    I went to the relationship and duplicated my table and then linked the ID field to the Photo field.

    I am not getting any errors but I am not getting any pictures in my database either. What am I missing? Thank you.

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    first off use an image control

    if it still doenst' work
    what is the value of Photos
    is it the full path or a relative path
    for now I'd suggest you add a text box underneath the image control and set its value to
    'C:\photos\" & Photos
    that will show you want the image control is being told to display
    check that its a valid path

    does this now mean you have given up on trying to do a discovery of files on a disk and instead are going to do it the old school way of entering data?

    I do not understand why you felt the need to duplicate your table. however to fully understand I'd guess we'd need to see the design of the two tables
    I'd rather be riding on the Tiger 800 or the Norton

  8. #8
    Join Date
    Dec 2005
    Posts
    21
    My photos are .jpg. They are in the C:\Photos folder. I did put a text box and put the expression that you instructed me to do. I get C:\Photos when I run the database.

    No I have definitely not given up on this. I appreciate your patience.
    I made another table thinking that I had to link the picture ID field with the photo field. I am a newbie trying to get my head around this.

    I have used Filemaker pro for years and it does a lot of the steps for you I am finding out now.

    I have my table where I have the Photo field. What do I put in the field? I tested two of the rows by putting in the C:\Photos\filename. But I know that is not right. Sorry. Thank you for your patience. I am still working on it.

    One more thing. The image control is the image box with the Mountains and the sun, correct?

  9. #9
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    if all you are seeing is "C:\Photos" AND you set the rowsource to 'C:\photos\' & Photos, then thats your problem
    either your column photos is blank or it doesn't exist

    I'd strongly recommend that you always force explicit declaration of variables


    open your table and see what values you have for the column photos
    check its called photos
    I'd rather be riding on the Tiger 800 or the Norton

  10. #10
    Join Date
    Dec 2005
    Posts
    21
    Yes my Photo column is blank. Every column has something in it but this column. How do I populate it? I do have the control source on my Form under the image control as ="C:\Photos\" & [photos].

    Not sure how to get a value in the photo column though.

    UPDATE:

    Ok, I went back to my master EXCEL sheet and made a column "photos" I copied all the id numbers into that column and then coded it to add the .jpg extension to each id number. Then I re-imported the spreadsheet into my database. That worked. Now I have all of my pics. Thank you for your help. I hope this was a viable way to do it. My database is only 68.9 mb doing it this way. Thank you again for being patient.
    Last edited by TaiChi56; 06-04-13 at 12:07. Reason: SOLVED

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •