How to change picture using Combox

mac300

Registered User.
Local time
Today, 15:16
Joined
Aug 9, 2007
Messages
12
I have a form, which has a combo box, with a list of states. I want to have a flag of each state, that will change automatically when I change the selection in the list.

Can anyone please explain how I can do this (if it's even possible?

Just to clarify, I don't want a link to the picture, I want it to actually show on the form.

(I use Access 2007)
 
In the After Update event for the combo, put some code that will check the current status of the 'flag'. Then hide/show (.Visible property) the picture as necessary.

Referencing a combo in VBA:

myVariable = Me.ComboName ' for the default bound column

myVariable = Me.ColumnName.Columns(n) ' for a specified column, where n is the number of the column and with the first column being 0.

So you could use:

Code:
[COLOR="blue"]If [/COLOR]Me.ColumnName = <a flag value> [COLOR="Blue"]Then[/COLOR]
    myPicture.Visible = [COLOR="blue"]False[/COLOR] [COLOR="SeaGreen"]' to hide the picture[/COLOR]
  [COLOR="blue"]Else[/COLOR]
    myPicture.Visible = [COLOR="blue"]True[/COLOR] [COLOR="seagreen"]' to show the picture[/COLOR]
  [COLOR="blue"]End If[/COLOR]

If there are multiple options in the combo you should probably consider a Select Case routine:

Code:
[COLOR="blue"]Select Case [/COLOR]Me.ComboName
  [COLOR="blue"]Case Is[/COLOR] = <value1>
    [COLOR="SeaGreen"]' Code[/COLOR]
  [COLOR="blue"]Case Is [/COLOR]= <value2>
    [COLOR="seagreen"]' Code[/COLOR]
  [COLOR="blue"]Case Is[/COLOR] = <value3>
    [COLOR="seagreen"]' Code[/COLOR]
  [COLOR="blue"]Case Else[/COLOR]
   [COLOR="seagreen"] ' Code[/COLOR]
[COLOR="blue"]End Select[/COLOR]
HTH

Tim
 

Users who are viewing this thread

Back
Top Bottom