Solved Display Image Conditionally (1 Viewer)

I would make sure the Lvl# fields are in the report's record source and included in the GroupHeader1 as bound controls. They don't need to be visible. Then, open the report's record source in datasheet view to make sure the Lvl# fields are valued (no nulls). Then, this code in the GroupHeader1_Format event should work. If you want to display the check box, that's fine but not necessary if the Lvl# fields are all valued with True/False Yes/No -1/0.

Code:
Private Sub GroupHeader1_Format(Cancel As Integer, FormatCount As Integer)

    Me.Lvl1Img.Visible = Me.Lvl1
    Me.Lvl2Img.Visible = Me.Lvl2
    Me.Lvl3Img.Visible = Me.Lvl3

End Sub
 
Lvl# fields are in the report's record source and included in the GroupHeader1 as bound controls
I would put my money that is what is going on. The OP forgot to bind the checkboxes, because that is about the only way you can return a null value. An unbound checkbox on a form or report returns null. In a form if you click it will become true, then false. Only if triple state is selected can you get back to a null state. But before it is clicked it is null even if not triple state. This assumes that what the OP says is correct.
Changing the expression to =me.Lvl1Ck throws RTE 94 Invalid use of Nul
 
Give @MajP 's suggestion a try. For example, change your above code to:

Code:
Me.Lvl1Img.Visible = Nz(Me.Lvl1Chk, False)
Me.Lvl2Img.Visible = Nz(Me.Lvl2Chk, False)
Me.Lvl3Img.Visible = Nz(Me.Lvl3Chk, False)
SUCCESS!!!
Thanks, Dave for seeing what I'd missed.
Thanks MajP for your correct diagnosis.
Thanks ALL for your informed analysis.
Where the Null is I'm not sure, but that did the trick.
 
SUCCESS!!!
Thanks, Dave for seeing what I'd missed.
Thanks MajP for your correct diagnosis.
Thanks ALL for your informed analysis.
Where the Null is I'm not sure, but that did the trick.
You should have tried looking at the report’s rexordsource in datasheet view. Nulls would have been apparent.
 
It is optional, but if you wish, you could mark the problem "Solved" by going back to the first post and see the option buttons above and to the right side of that first post. "Solved" is one of the options. Since you are new to the forum, I'll explain that when we look at problems, the ones that are solved let us know that we can work on something else. AND they let the other new members see that they might find a solution if they have a similar problem. It's a feedback thing. Certainly NOT mandatory - but we think of it as a nice touch.
 
SUCCESS!!!
Thanks, Dave for seeing what I'd missed.
Thanks MajP for your correct diagnosis.
Thanks ALL for your informed analysis.
Where the Null is I'm not sure, but that did the trick.
Well the Null is in the checkbox control?
That is why you need to use the NZ() function.
 
Thanks for the orientation/mentorship Doc_Man. Props where due. Thanks all!
 

Users who are viewing this thread

Back
Top Bottom