Show image based upon combo box value

Johnny Drama

In need of beer...
Local time
Today, 15:12
Joined
Dec 12, 2008
Messages
211
I've searched high and low through the forums and tried every piece of code I can find, but I still can't get this to work.

I've got a report with a combo box and an embedded image. The name of the combo box is deferrable and the image control is name Flag. I using the below code:

Private Sub Report_Load()
If Me.Deferrable = "Yes" Then
Me.flag.Visible = True
Else
Me.flag.Visible = False
End If
End Sub

If I set Deferrable to "No", then the image shows up, if I set it to "Yes" then no images appear. I want an image to appear next to all the records in the report that meet the "yes" criteria. This is driving me nuts.
 
If you want that to apply to each record individually, it needs to be in the detail format event.
 
Put in the On Format event in the detail section and it didn't work. As a matter of fact, now it just shows the image regardless of whether I set the variable to yes or no.
 
What view are you using? The format events don't fire in the new Report view.
 
Either that or Me.Deferrable is always True.

By the way, if it's an Image control and you're getting images from a path you can put this in its Control Source property:
Code:
=IIf([[COLOR=Red]Deferrable[/COLOR]], [[COLOR=Red]ImageField[/COLOR]], "")
 
@ pbaldy - I've now tried both the report view and print preview, but no dice.
@vbaInet - Not sure what you're referring to in your first sentence, but I'm not getting images from an image path. It is embedded, 1K in size, and the only one I'm using.
 
It means the value of Me.Deferrable is not changing. It remains as True. This is in reference to your post #3.

The code I provided won't work for you in that case. Stick to your original method.
 
Can you post the db here?
 
It's huge. Let me see if I can pull just what I need to demonstrate the problem and get it posted.

Okay...pared it down to just what is need to demo the problem. Have at it.
 

Attachments

Last edited:
It's a yes/no, field, not text:

If Me.Deferrable = Yes Then
 
Actually that seems to produce the reverse result, so you want the actual value:

If Me.Deferrable = -1 Then
 
That makes two of us, but having it in a combo threw me off. I expected a text value in a combo.
 
That makes two of us, but having it in a combo threw me off. I expected a text value in a combo.
Me too, it's only logical. Even a checkbox will occupy less space so I wonder why he chose a Combo box. :confused:
 
Hey guys,

Thanks for the help. Chose a combo box because the people viewing the report don't have the best of vision and have asked to see something other than a small check, which is what I initially had. Even the yes and no befuddles them sometimes so I wanted to add the flag image to really make it stand out.

I've tested it based upon the comment you made and it still doesn't appear to work though. Not sure what I'm missing.
 
No problem, glad we got it sorted out.
 
I spoke too soon. It still doesn't seem to work. I changed it to:

If Me.Deferrable = -1 Then
Me.flag.Visible = True
Else
Me.flag.Visible = False
End If

but nothing seems to happen.
 
What event do you have it in, and what view are you opening the report in?
 
ChaChing...I forgot it had do be viewed in Print Preview. Works great. Thanks guys!
 
Happy to help. The format events work in Preview or Print, but not Report view.
 

Users who are viewing this thread

Back
Top Bottom