469,323 Members | 1,552 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

How to make image on report visible using yes/no field as criteria

I have an image on my report that I want to make visible only when a yes/no field is true. The yes/no field is a hidden text box called txtTried. The code I've been trying to use is:
Expand|Select|Wrap|Line Numbers
  1. If Me!txtTried = True Then
  2.     Me.imgBerry.Visible = True
  3. Else: Me.imgBerry.Visible = False
  4. End If
I got this to work on a form by using the same code in the Form_Current event, but it won't work in my report. Have tried it in the Report_Current, Report_Activate, Report_Load, Report_Open, and Detail_Format events, nothing happens in any of those except the Report_Open one gives an error saying can't find the field, control, or property, and in debug mode the first line of code is highlighted.
Not sure if I'm making sense, can anyone help me with this?
Oct 5 '10 #1

✓ answered by ADezii

  1. The [Tried] Field in the underlying Data Source should be a Yes/No Field represented by a Check Box, and not a Text Box.
  2. Change the Control Name to chkTried in the Detail Section of your Report.
  3. Place the following, single line of Code, in the Format() Event of the report's detail Section.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    2.   Me![imgBerry].Visible = Me![chkTried]
    3. End Sub

4 8887
ADezii
8,800 Expert 8TB
  1. The [Tried] Field in the underlying Data Source should be a Yes/No Field represented by a Check Box, and not a Text Box.
  2. Change the Control Name to chkTried in the Detail Section of your Report.
  3. Place the following, single line of Code, in the Format() Event of the report's detail Section.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    2.   Me![imgBerry].Visible = Me![chkTried]
    3. End Sub
Oct 5 '10 #2
NeoPa
32,173 Expert Mod 16PB
From your question it's not clear if the Yes/No control you refer to (as a field) is on the form still, or has been duplicated to the report to match a field in the record source. If the former, then you will have problems referencing the control. We could help with that if more info were available. If the latter then ADezii's post should solve your problem. The control should certainly be a CheckBox and not a TextBox, and the code he provided is preferable to yours, which should work fundamentally, but is overly complicated for the task. If so, you may choose to mark his post as the best answer.
Oct 5 '10 #3
Yes I did have the yes/no field on the report as well, so changing it to a checkbox and changing the code did get it all working. If only experience with code-writing was something that could be gotten quicker!
Thank you both so much for your help :)
Oct 5 '10 #4
NeoPa
32,173 Expert Mod 16PB
It's a pleasure, and especially so when members display such good manners :-)
Oct 6 '10 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by spamfurnace | last post: by
6 posts views Thread by Patrick Olurotimi Ige | last post: by
reply views Thread by Vikramaditya Singh | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.