Make field with Image disappear if empty

In the Load event of the report, can you get the LEFT property of one your textboxes using this syntax:
Code:
Msgbox Me.TextboxName.Left
 
What what means? You need to be more explicit. You don't know where to put the code or what the Load event is?
 
Look at the attached image.

Right-click the black square dot > click Properties
 

Attachments

  • Properties.png
    Properties.png
    31 KB · Views: 166
Ok, I found it. So now I have a text box for my image field and the syntax you gave me in the on-load part. Now what?
 
I need you to use that code and get me the Left of one of those textboxes that you want to move left when there's no image in the Image control.

Click the elipsis button in that property > select Code Builder > Ok it.
Replace textboxName with the name of one of the textboxes, place the code between the Private Sub and End Sub lines > open the report in Print Preview and tell me what the msgbox reads.
 
So going forward, whenever the word "event" is mentioned you know what to look for and where to find it.

On that note, do you know how to get to the Print event or Format event of the VPOrgName Header section?

Remind me how you determine when the record has no pic? There's no path?
 
=IIf(IsNull([Image_tbl2DR]),"",[Image_tbl2DR])

This is what I'm using in my image box. It sits by itself to the left of the 2 text box lines. Those textbox lines also have the IsNull in them so they disappear when they are empty. The image box still shows up.
 
What I mean is, what is the source of the image? Is it saved in a table or is it pointing to file path?
 
Lovely job!

Put this in the Format event of that section:
Code:
Me.[Image_tbl2DR].Visible = Not IsNull([Image_tbl2DR])

If IsNull([Image_tbl2DR]) Then
    Me.[COLOR=Blue]TextBoxName[/COLOR].Left = 0
Else
    Me.[COLOR=Blue]TextBoxName[/COLOR].Left = 550
End If
So replace TextboxName with the name of the first textbox in that section and see how it works. Once you have it working, you can include the other textboxes.
 
Ok - I did that. Got a Compile Error: method or data member not found

It highlighted the ".Visible ="
 
Look for the name of the image control and substitute [Image_tbl2DR] for that. I believe [Image_tbl2DR] is the field name.
 
The name of my actual image is "Image" from table "tbl2DR". I'm getting the following error message now and maybe it's because I didn't do the line items right below.

Message say: The Expression On format that you entered as the event property setting produced the following error: Can't execute code in design mode.

Me.[tbl2DR.Image_tbl2DR].Visible = Not IsNull([tbl2DR.Image_tbl2DR])
If IsNull([tbl2DR.Image_tbl2DR]) Then
Me.Text1190.Left = 0
Else
Me.Text1190.Left = 550
End If


What did I do wrong?
 
Hmm, for starters you do not need the reference to the table since you have Me., and you need to supply the controls name since that is what your setting the visibility of. When you set the visibility of a control it must = True or False

Me.ControlName.Visible=True or False

Also, you can only set the visiblity of the control if it is not a continuous form assuming this is in the detail portion.
 
The name of my Image box is field [Image] from my tbl2DR table. This is what I have in that code:

Me.Image.Visible = Not IsNull([tbl2DR.Image_tbl2DR])
If IsNull([tbl2DR.Image_tbl2DR]) Then
Me.Text1190.Left = 0
Else
Me.Text1190.Left = 550
End If
 

Users who are viewing this thread

Back
Top Bottom