Changing a picture based on combobox selection

vidus

Confused User
Local time
Yesterday, 23:36
Joined
Jun 21, 2009
Messages
117
I would like to set up a picture in the form that changes based on a combobox selection, for example if you select "red", a picture of the color red will appear in the form.

I know this can be done because I have done a lot of searching on the subject, the problem is everything says to just "set up a relational image afterupdate blah blah blah.. but I dont know how to do any of that... Im starting from bare basics here.

Is there any actual step by step instructions anyone knows of? I also have bought access 2007 the missing manual... but it does not mention how to do this.
 
Have a look at the attached sample DB.

The search function on this forum is also pretty good for finding solutions to most questions.
 

Attachments

Have a look at the attached sample DB.

The search function on this forum is also pretty good for finding solutions to most questions.


thanks for the example, but im not seeing any changes based on selection... seems nothing happens?
 
Here's another example.

You will need to copy the four images into a folder called Flags, this folder must be in the same location that you copy the DB to. ie. if you copy the DB to your desk top put the folder Flags on the desk top also.

Also check the form's On Load event and the Combo's On Change event
 

Attachments

Works for me. Are you using Access 2007, per chance and have you done this?

Thanks, it was the trusted location.

It works now, and Ive tried in vain for the last while to get it to work on my DB but I just cant get it working... I just dont get how to set it up from scratch... I dont know what to copy and where. Just doesnt make sense. I would prefer throwing the computer through the window at this point im so frustrated.
 
The first DB Posted relies on having a number of static images on the form, the visibility of which is switched on or off by the Combo's After Update event, as well as the Form's On Current event. Have a look at those two events, you will find that the code is very similar, and simply tests what the current value of the Combo is and then shows or hides the appropriate image.

The second example I posted, only has the one image holder and the image that is displayed is determined by the, image location selected by the, combo box, once again the combo's On Change event and the form's On Current event are used.

The forms On Current event is used to determine what image should be displayed when the form loads and when a new record is selected. The Combo's After Change event is used to detect changes made to the value of the combo. This applies for both methods.
 
The first DB Posted relies on having a number of static images on the form, the visibility of which is switched on or off by the Combo's After Update event, as well as the Form's On Current event. Have a look at those two events, you will find that the code is very similar, and simply tests what the current value of the Combo is and then shows or hides the appropriate image.

The second example I posted, only has the one image holder and the image that is displayed is determined by the, image location selected by the, combo box, once again the combo's On Change event and the form's On Current event are used.

The forms On Current event is used to determine what image should be displayed when the form loads and when a new record is selected. The Combo's After Change event is used to detect changes made to the value of the combo. This applies for both methods.

Thanks for the clarification.. ill give it another shot. I think my problem is that I have about 15 colors to produce images for which gets to be a bit much.. something is not working just yet.
 
The second method will be the way to go given you have more than a couple of images.
 
Good day everyone,

I am newbie here. I made a search in google and found this link.

John, I downloaded the samples you provided, but I am using
Access 97 (prehistoric..). Appreciate if you can narrate the steps.

Many thanks,
adal
 
Try this version saved back to 97 format. Once again copy the images into a folder, called Flags, that is in the same location as the DB.

In short The combo has a hidden column that contains the path for the Image files. This is displayed in the text box below the combo.

There is also some code in the forms OnLoad event and the combo's OnChange event to tell the Image frame were to find the image.

Code:
Me.Image5.Picture = Me.Combo2.Column(2)
 

Attachments

Last edited:
Login User name in Data entry Form

Dear……

I have developed an Inventory Database but facing some problem….

In the database there are some user names for entering the database. And the users have permission to input data. But I need to ensure the user names, who do input a specific data/record in the database. For this purpose it is necessary to show the user name (that is used for Login in the login Form) in the Data Entry Form and as well as in the main Database Table.

A sample of my database is attached herewith. It will be very much helpful if any one can help me in the above issue updating the attached database as per my need. Or giving another sample...

Thanks
 

Attachments

Rana, it would probably be worth starting a new thread. As what you are looking at is beyond the scope of this thread.

There are a whole lot of issues that your question raises that would be answered better in their of own thread.
 
i want to link a picutres i mean web pictures please do suggest

Rana, it would probably be worth starting a new thread. As what you are looking at is beyond the scope of this thread.

There are a whole lot of issues that your question raises that would be answered better in their of own thread.
 
To display a web image in a form, I believe you will need open it in a browser embedded in your form.
 
The first DB Posted relies on having a number of static images on the form, the visibility of which is switched on or off by the Combo's After Update event, as well as the Form's On Current event. Have a look at those two events, you will find that the code is very similar, and simply tests what the current value of the Combo is and then shows or hides the appropriate image.

The second example I posted, only has the one image holder and the image that is displayed is determined by the, image location selected by the, combo box, once again the combo's On Change event and the form's On Current event are used.

The forms On Current event is used to determine what image should be displayed when the form loads and when a new record is selected. The Combo's After Change event is used to detect changes made to the value of the combo. This applies for both methods.


Sorry for digging this one up from 3 years ago but i found it with a search.
When my form loads i get the following error message

"Runtime error 94;
Invalid use of Null

I get the same error if i try to make a selection using the combo box. My combo box is called Combo309 and the image box is called Image5. The combo box values come from a table where there are 15 options listed and each option has the path to the image i want in the next field. I'm using both fields in the combo box. Hope i've explained it ok. Thanks

Code:
Private Sub Combo309_Change()
    Me.Image5.Picture = Me.Combo309.Column(2)
End Sub
 
Private Sub Form_Load()
    Me.Image5.Picture = Me.Combo309.Column(2)
End Sub
 
I'm guessing that your Combo does not have a default value set. Try setting a default value for the combo.

Alternately try using the Nz() function to provide a path to an image prior to a selection being made in the combo;
Code:
Me.Image5.Picture = Nz(Me.Combo309.Column(2), "C:/pathDefaultImage.JPG")
 
Hi John, thanks for replying. I put the code you posted into the OnLoad event of the form, along with the correct path to the default file and the error message no longer appears. However when i make a selection from the combo box i'm getting the same error again

"Runtime error 94;
Invalid use of Null


When i click the Debug button, the line 'Me.Image5.Picture = Me.Combo309.Column(2)' is highlighted in yellow


Code:
Private Sub Combo309_AfterUpdate()

    Me.Image5.Picture = Me.Combo309.Column(2)
End Sub


Thanks for your help
 
Remember that the columns in a combo are numbered from Zero on up, so the first column is column(0) and the second Column(1). So ensure that you have referenced the correct column.
 

Users who are viewing this thread

Back
Top Bottom