Results 1 to 12 of 12
  1. #1
    cpotter is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    6

    change image based on combo box selection

    Hello! I am new to this forum and this is the first time I have posted.

    I have a picture/image field on form that needs to update based on combo box selection. The number of choices from the combo box is great. How would I code this so the corresponding picture changes? I have seen answers based only a few images, but my combo box has quite a few choices each matched to a picture.

    Thanks you,
    CPotter

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Is the picture embedded in Attachment field or saved externally? Can use an expression in Image control ControlSource property to construct path to external image.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    cpotter is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    6
    Quote Originally Posted by June7 View Post
    Is the picture embedded in Attachment field or saved externally? Can use an expression in Image control ControlSource property to construct path to external image.
    The pictures are saved externally in same drive, different folder.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    So what does the combobox have - full file path and filename with extension (.jpg, .bmp, etc)?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    cpotter is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    6
    Quote Originally Posted by June7 View Post
    So what does the combobox have - full file path and filename with extension (.jpg, .bmp, etc)?
    I apologize, I think I was not clear before. The combo box is ID numbers, as text field though. I need to know how to connect the combo box info (the ID numbers) to the corresponding picture (named same as the ID number) so the picture changes when the combo box selection changes.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Need full file path for the image in the ControlSource property. This can be changed dyanmically by an expression that references combobox. Are all images in the same folder?

    ControlSource expression like:

    ="C:\folder path\" & [combobox name] & ".jpg"

    If the folder is on central server and this db will be used on multiple computers, suggest using UNC path instead of static drive mapping.

    = "your server name\\folder path\" & [combobox name] & ".jpg"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    cpotter is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    6
    Quote Originally Posted by June7 View Post
    Need full file path for the image in the ControlSource property. This can be changed dyanmically by an expression that references combobox. Are all images in the same folder?

    ControlSource expression like:

    ="C:\folder path\" & [combobox name] & ".jpg"

    If the folder is on central server and this db will be used on multiple computers, suggest using UNC path instead of static drive mapping.

    = "your server name\\folder path\" & [combobox name] & ".jpg"
    Does this path need to be in the control source of an unbound object or in image field. Here is what I put in my controlsource ="M:\Access Stuff\Pics" &[comboboxname]&".jpg" for the image It did not bring anything up. If I point it to a particular picture is does not change. Do I need to include a requery or put something in the after update on the combobox events. Also, thank you for putting up with basic questions.

  8. #8
    cpotter is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    6
    Okay, I think I am getting there. Right know if will go to the first selection, but after that is it will not change again.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I've actually never tried to use combobox as parameter for Image control ControlSource. I have used dynamic expression that references a field of the form RecordSource. In that case the Image control reflects correct image for each record. What you are doing should display same image for all records of the form. Might have to refresh the form, in which case the form will automatically move to the first record.

    I don't have time right now to build something and test. If you want to provide db, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by cpotter View Post
    Does this path need to be in the control source of an unbound object or in image field.
    I use an image control to dynamically display images on a form. When I first create the control, I have the wizard turned on. I select a temp image that is sized approx. to the size I will be using in my form.

    After I create the image control I give the control the name I want and save the form.

    Then I clear the Picture property for the Image Control. Access will ask you if you want to delete the image. Answer yes and save the form.

    Now you can dynamically update the Picture property of the Image Control. Use your image path as June7 explained in post # 6

  11. #11
    cpotter is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    6
    Thank you for all your help, but I think I have it figured out. I coded the following a test db in the after update of the combobox:

    me.[image name].picture="c:\\filepath\"&[comboboxname]&".jpg"

    I will code my db at work on Monday and cross my fingers.

  12. #12
    statman is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2013
    Location
    indiana
    Posts
    3
    Another good place to store the pictures is on dropbox public file or something similar so that anyone who is using your program does not have to set the database paramaters.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 04-29-2013, 04:23 PM
  2. Replies: 3
    Last Post: 12-11-2012, 09:12 AM
  3. Display image based on combobox selection?
    By 10 Gauge in forum Forms
    Replies: 2
    Last Post: 09-15-2011, 07:42 AM
  4. Image change based on combo box
    By bosve73 in forum Forms
    Replies: 4
    Last Post: 08-09-2010, 02:23 AM
  5. Replies: 1
    Last Post: 10-19-2009, 02:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums