Results 1 to 5 of 5
  1. #1
    bosve73 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    22

    Image change based on combo box

    Hi

    I have very simple database consisting of one table "tblMain" and one form
    "frmMain". On the form i have a two cascading combo boxes and two text box which get their data from combo boxes.



    The issue that I have is I am trying to add image to my form which is based on selection in a combo box so that Selection1->shows image1 and so on. As a novice to Access I have searched the forum but there are so many diffrent solutions that I don't know where to begin.

  2. #2
    trb5016 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Location
    Pennsylvania
    Posts
    71
    First on your form add an image as a placeholder. Do this by selecting the Image button (near textboxes and combos etc)

    Drag it over the area you want to cover. It will ask you to select an image. I'd choose whatever picture you want the default to be. (I'm pretty sure it forces you to have some image in there, though I could be wrong - you might also be able to use an unbound object frame, anyone?)

    Now change the Control name of this image to something better than Image1 or whatever.

    Now on your combobox, use the "AfterUpdate" Property. In there put code that could look something like this

    Code:
    Select Case [YourComboBox].Value
    
       Case "Choice 1"
          [YourImageName].Picture = "C:\YourPathToPicture\YourPicture.jpg"
       
       Case "Choice 2"
          [YourImageName].Picture = "C:\YourPathToPicture\YourPicture2.jpg"
    
    End Select
    You can of course have a bajillion ways to choose the image other than a select case, but that's what I normally use for comboboxes

    The important property here is the .Picture

  3. #3
    bosve73 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    22
    Quote Originally Posted by trb5016 View Post
    First on your form add an image as a placeholder. Do this by selecting the Image button (near textboxes and combos etc)

    Drag it over the area you want to cover. It will ask you to select an image. I'd choose whatever picture you want the default to be. (I'm pretty sure it forces you to have some image in there, though I could be wrong - you might also be able to use an unbound object frame, anyone?)

    Now change the Control name of this image to something better than Image1 or whatever.

    Now on your combobox, use the "AfterUpdate" Property. In there put code that could look something like this

    Code:
    Select Case [YourComboBox].Value
     
       Case "Choice 1"
          [YourImageName].Picture = "C:\YourPathToPicture\YourPicture.jpg"
     
       Case "Choice 2"
          [YourImageName].Picture = "C:\YourPathToPicture\YourPicture2.jpg"
     
    End Select
    You can of course have a bajillion ways to choose the image other than a select case, but that's what I normally use for comboboxes

    The important property here is the .Picture
    I am probably missing something but it does not work when i test it.
    No errors at all but nothing happens either when I do a selection in combo box.

  4. #4
    trb5016 is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Location
    Pennsylvania
    Posts
    71
    Hrm, is the event actually being fired? Try putting a line of code to debug like

    Msgbox("This should be changing the picture now")

    Also I whipped up a quick sample for you (Attached)

  5. #5
    bosve73 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2010
    Posts
    22
    Quote Originally Posted by trb5016 View Post
    Hrm, is the event actually being fired? Try putting a line of code to debug like

    Msgbox("This should be changing the picture now")

    Also I whipped up a quick sample for you (Attached)
    Ok i got it working now. Thanks!

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

Similar Threads

  1. Replies: 3
    Last Post: 07-05-2010, 10:46 PM
  2. Change image directory
    By amer in forum Access
    Replies: 3
    Last Post: 06-09-2010, 07:01 AM
  3. Updating subform based on combo box change
    By kev921hs in forum Forms
    Replies: 3
    Last Post: 04-01-2010, 08:43 AM
  4. Replies: 1
    Last Post: 10-19-2009, 02:37 AM
  5. Replies: 1
    Last Post: 08-26-2009, 10:45 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