Reputation: 3
I have a table in Access that has comments in one field and a file path to an associated picture in another. My report has the comment and then an image bound to the file path field underneath that comment. However, most comments do not have a picture with it, and the empty space between comments makes the report unnecessarily long.
Is there a way in VBA to only add an image control if there is a file path and minimize the spacing between the pictureless comments?
Upvotes: 0
Views: 1628
Reputation: 1692
You can't add any controls to a report when Access is in Runtime mode. But you can easily resize the image control using VBA in one of the Report's Format
methods. Assuming your Image control is named "Image1", and it is in the Detail section:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Me.Image1.ImageHeight = 0 Then
Me.Image1.Height = 144 ' whatever minimum height you want
Me.Detail.Height = 144
Else
Me.Image1.Height = 1440 ' whatever the normal Image1 height is
Me.Detail.Height = 1530 ' whatever maximum detail height you want
Endif
End Sub
That should be very close to what you need.
Upvotes: 1