Can Shrink an Image Field?

M

Melinda

I have a table which has a field for a picture - data type is OLE Object.
Some (but not all) records have a picture pasted in this field (enhanced
metafile). In a report based on this data, I need to include the picture if
there is one, but if there is not a picture I need the report to not have the
big gap (empty space set up for the image field). Is there a way to tell
access if the image field is null, to shrink that field in the report?
 
L

Larry Linson

Neither the Image, Unbound OLE Frame, nor Bound OLE Frame have
CanGrow/CanShrink properties.

I recall, in the past, using VBA to try to adjust sizes and don't remember
the outcome. If I had a little more time and energy, I'd look into that,
but, alas, both time and energy "come at a premium", these days.

Should you decide to pursue that, put your VBA code in the Format event.
I'd be using an Image Control, with the "external file approach" described
in the examples I will later reference. I'd check to see if the path and
filename of the image were Null, then I'd set the height and width
properties of the Image Control to a miniscule amount. If the path and
filename of the image was not Null, I'd reset the height and width of my
Image control to the default. The Detail Section does have CanGrow and
CanShrink, but don't know if that'd be useful in this situation. You could
try adjusting the height of the Detail Section, too. Sorry I don't remember
whether this worked, before.

Regards,

Larry Linson
Microsoft Office Access MVP
 
S

Stephen Lebans

Here is a previous post of mine on this issue:

You can certainly resize an OLE Frame control or even an ActiveX control
at runtime for a Form or a report. If you convert the sample Form to a
Report in the AutosizeOLE solution on my site you will be able to verify
this. THe real issue is that once you programmatically resize any
control, the Detail section will never shrink smaller than the tallest
value your resizing forced the section to become.
With A2K or higher this issue has been resolved in that now it is
allowed to resize the Detail section from within the Format event.


Back to the OP's issue. Since they are working with a fixed size OLE
Frame control and do not need autosizing, I would simply set the
control's Visible prop to false in the Format event when the control
contains no data.


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
' Set the OLE Frame control's Visible prop to NO if empty.


If IsNull(Me.OLEBoundAutosize.Value) Then
Me.OLEBoundAutosize.Visible = False
Else
Me.OLEBoundAutosize.Visible = True
End If


End Sub



--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
F

Fran?ois Yenny

Stephen,

I have the exact same issue for which you suggested a solution. However, I would greatly appreciate it of you would please elaborate on how to implement it.

Not only have I never used code in Access before, but I work with a french language version of the program which makes it hard for me to find the controls you refer to.

Thank you,

F. Yenny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top