StrikeEagleII
Technical User
I have a report in which the detail section contains an Image frame (that is set to an image on the fly) and a text box for the image caption. They are arranged such that on the page they side by side, though typically the image is much bigger than the caption. The filename of the image and how big the image frame needs to be are stored in the database. In the Detail Section Format event, I set the size of the image frame as well as the picture it is to display. The height of the caption textbox is defaulted to 0 so that the detail section can essentially not be shown for records that do not have images. The Can Grow property is set to Yes so that if there is caption text it will be shown.
The problem is that after I set the image frame's height and the detail section's height, Access automatically causes the detail section to grow an additional amount that is equal to how much the image caption text box needed to grow, even though the section is already large enough and doesn't need to grow. This can be fixed by setting the detail section's Can Grow property to No, but I don't know that I want to do that since it is conceivable that the image caption textbox would be bigger than the image and then would the section would need to grow. In that case, I can't just set the detail height to the caption textbox's height, because in the detail format event, the textbox has not yet "grown". The initial top and height of the image frame and caption text box is 0. Any ideas?
The problem is that after I set the image frame's height and the detail section's height, Access automatically causes the detail section to grow an additional amount that is equal to how much the image caption text box needed to grow, even though the section is already large enough and doesn't need to grow. This can be fixed by setting the detail section's Can Grow property to No, but I don't know that I want to do that since it is conceivable that the image caption textbox would be bigger than the image and then would the section would need to grow. In that case, I can't just set the detail height to the caption textbox's height, because in the detail format event, the textbox has not yet "grown". The initial top and height of the image frame and caption text box is 0. Any ideas?
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Nz(me.txtImageFilename) <> "" Then
'this record has an image. Resize frame and display it
ImageFrame.Picture = strfolder & Me.txtImageFilename
ImageFrame.Height = Me.txtImageHeight
ImageFrame.Width = Me.txtImageWidth
Me.Detail.Height = Me.ImageFrame.Height
Else
'no image on this record
Me.ImageFrame.Height = 0
Me.Detail.Height = 0
End If
End Sub