Graphic Images in Access Report


Graphic Images in Access Reports

Add Large Graphic Images Into a Report at Run-Time

Have you ever tried to produce a Microsoft Access report that has a complex government or state form overlaid as a image on which you place the data/text fields? If you have had my experience you find that a few 100 kilobytes jpeg image turns into 30 megabytes when inserted into an Access report.  If you have several of these jpg images then soon your database grows to 100’s of megabytes in size and gets slow and fragile.

The trick is to dynamically overlay graphic images at runtime. To do this you’ll need to line up the data fields using a temporarily inserted picture as shown below:

Important points are to get the size of the image just right so that it is not too large for the paper.  Before resizing you must change the Size Mode Property from Clip to Zoom otherwise the image will get distorted.  Once the picture is sized to fit on the paper then we overlay the data fields on to the image at the appropriate locations.  Note that it is best to change the Back Style property of the text fields from Normal to Transparent.  This will make it so the text fields won’t obscure part of the form such as the underline in the Name / Address fields.

The next step is to remove the picture – but don’t delete it.  Change the Picture Property from the location of the form’s image to blank (delete the entry).  Access will change this field to (none).

See below:

Now, the final step is to write a little bit of VBA code so that the image will be inserted into the report at time of printing:

Option Compare Database.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.Form_Image.Picture = “c:access 2000santen.jpg”
End Sub

Note that this is event is the Format event of the Detail section.

Now, when the report is run you get the form image dynamically inserted into the report:

With this technique your database will not bloat up to 100’s of megabytes.

Microsoft Access 2013 2010 All Windows Versions


Microsoft Office VBA, MS Access 2003, 2007, 2010, 2013, 2016