0

我在 Access 中有一个表,其中一个字段中有注释,另一个字段中有关联图片的文件路径。我的报告有评论,然后是一个图像绑定到该评论下方的文件路径字段。但是,大多数评论都没有图片,评论之间的空白使报告不必要地冗长。

如果有文件路径并最小化无图片注释之间的间距,VBA 中是否有办法仅添加图像控件?

4

1 回答 1

1

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.

于 2018-07-11T21:13:25.457 回答