Insert and resize a picture in an access report

試著忘記壹切 提交于 2020-07-23 07:45:32

问题


I am starting an Access database with exam questions. Almost every question will have a picture attached to it. I would prefer not to save the pictures in the database to keep it small.

I want to insert these pictures in a report. The pictures must all have the same width (the width of the report), but the height must be resized according to the original aspect ratio. Some pictures are landscape and others portrait.

I have now spent three days trawling the internet and still can not find a workable solution. It does not seem like this should be SO difficult!?

I am using Office 365, VBA 7.1 and Windows 10. I am not a programmer and last used Access a looong time ago (Access 97).

PLEASE HELP.

Isabella


回答1:


In the end it was very simple. I am posting the solution, maybe it will save somebody else three days.

Just to explain the names.

ImageSource is a text box that contain the path of the file.

ImageFrame is an empty image that I placed on the report.

The code is placed in the OnFormat section of my GroupHeader on my Report.

The 9996 is a little smaller than the width of my report and it is in twips.

This is the code:

Private Sub GroupHeader3_Format(Cancel As Integer, FormatCount As Integer)
    Me![ImageFrame].Picture = Me![ImageSource]
    Me![ImageFrame].Width = 9996
    Me![ImageFrame].Height = 9996 * Me![ImageFrame].ImageHeight / Me![ImageFrame].ImageWidth
End Sub


来源:https://stackoverflow.com/questions/47937322/insert-and-resize-a-picture-in-an-access-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!