Image Visibility

MHutcheson

Registered User.
Local time
Today, 19:41
Joined
Sep 3, 2013
Messages
23
Hello,

I am using Access 2010 32-bit and I have placed an embedded image (Image146) in the detail section of a report, and then set the Visible property to No.

There is a Text box (field1) also in the detail section. When the value of the Textbox = "ABC" I want the image to display, otherwise stay invisible.

So far I have tried the following to no avail while displaying in Print Preview:

1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If Me.field1.Value = "TN11" Then
Me.Image146.Visible = True
Else
Me.Image146.Visible = False
End If
End Sub

2. Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If Me.field1.Value = "TN11" Then
Me.Image146.Visible = True
Else
Me.Image146.Visible = False
End If
End Sub

3. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.Image146.Visible = (Me.field1.Value = "TN11")
End Sub

The image is not displaying at all - any ideas?

Regards,

Michael
 
Hi MHutcheson, Welcome to AWF.. :)

Have you tried the Report_Current method?
 
Hello pr2-eugin,

Thanks for the reply.

Yes, just tried

Private Sub Report_Current()
If Me.field1.Value = "TN11" Then
Me.Image146.Visible = True
Else
Me.Image146.Visible = False
End If
End Sub

and also

Private Sub Report_Current()
Me.Image146.Visible = (Me.field1.Value = "TN11")
End Sub

To no avail...
 
Did you try Debugging?
Code:
Private Sub Report_Current()
     MsgBox Me.field1
[COLOR=Green]'    If Me.field1.Value = "TN11" Then
'        Me.Image146.Visible = True
'    Else
'        Me.Image146.Visible = False
'    End If[/COLOR]
End Sub
See what value you get..

PS: Please use Code Tags when posting VBA Code
 
Hi Paul,

No sorry, I haven't tried that - I've never used debugging before though in Access\VBA.

I don't understand why its not working, I must be missing something.

Regards,

Michael
 
So have you used the code in Post#4? Did you get the expected value in the MsgBox when you open the report?
 
Apologies Paul,

Yes I tried this in the On Current event of the report and got nothing, but if I put the code into the Detail On Format event, I do get the pop up, so it must be something specific about the image properties...

Regards,


Michael
 
Hey Paul,

I got this to work but it's not ideal. Basically if I add another text box in the detail section then for it's control source state if Field1 = "ABC" then YES else NO, then in the Detail On Format enter the following:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
' MsgBox Me.field1
If Me.Text149.Value = "YES" Then
Me.Image146.Visible = True
Else
Me.Image146.Visible = False
End If
End Sub

The image only displays where there is a yes value. In summary, it looks like you can only set the visibility of images using VBA in the report based on another field if the other field is Boolean. If that makes sense.

Unless of course I am completely wrong - which has been known!

Regards,

Michael
 
Okay what is field1 is this a Control or a Column in the RecordSource?
 

Users who are viewing this thread

Back
Top Bottom