Show or Hide image based on value (1 Viewer)

WineSnob

Not Bright but TENACIOUS
Local time
Today, 11:13
Joined
Aug 9, 2010
Messages
211
I am trying to show or hide an image based on the detail records value.
I want to show a Green up arrow image If Me.IncomeFromActual > Me.EstIncome or show a Red Down Arrow If Me.IncomeFromActual < Me.EstIncome. The actual report has 15 records and some should show red arrow and some should show green arrow but ALL show green which is the correct image for the first record.
Here is what I have:

Private Sub Report_Load()
Me.ImageRed.Visible = False
Me.ImageGreen.Visible = False

If Me.IncomeFromActual < Me.EstIncome Then
Me.ImageRed.Visible = True
End If
If Me.IncomeFromActual > Me.EstIncome Then
Me.ImageGreen.Visible = True
End If

End Sub
 
Try the detail format event rather than the load event.
 
Thanks AGAIN Paul. You're the best!
 
Happy to help Rick!
 
Hi,

I had the same problem and used the same solution but it's working only for print preview mode (event format seems not triggered in reportview mode).

Does someone know a solution for the reportview mode?

Thanks
cheers
 
You are correct, the event doesn't fire in that view. Have you looked at Conditional Formatting?
 
Hi,

the field used to control the display of the image is a boolean, a tick box then.
I didn't see any conditional formatting for this type of control.
Anyhow, the idea I have so far, is to modify the property visible of the image according to the value of the field. Again it seems there is no conditional formatting for the images.

I tried with event paint but I get an error message that I can't change this visible property within this event...
 
I believe that you are correct that you can't use CF on an image. I know you can format in the paint event, but it appears you're also correct about the error, as I got it in a brief test too. Not what the solution is offhand. Is there a reason you're using report view? I've used it once or twice, but overall haven't seen a lot of use for it.
 
Hi Paul,

thanks!

Well, I use a Report as it´s a way to see a bunch of record in a view better than a table view (fields are long) and close to what I´ll get when printing.
It´s true that a continuous form could have been but I think the issue is the same.

Anyhow, I let the tickbox when in reportview and change to image present or not when in print preview mode.
Not as nice as I hope but good enough.

Thanks
 

Users who are viewing this thread

Back
Top Bottom