Creating a report that will display a number of images from filenames in a table

前端 未结 1 1650
春和景丽
春和景丽 2020-12-22 01:59

I have a VBScript that I use to read an XML file and populate a couple of tables in Access 2010. The VBScript also copies jpg files from a card reader to a location on the s

相关标签:
1条回答
  • 2020-12-22 02:40

    You can do what you describe using an Image control and a line of VBA code. For a sample table named [ImageLocations]

    ImageLocation                           
    -----------------------------------
    \\SERVER\Public\Pictures\image1.jpg        
    \\SERVER\Public\Pictures\image2.jpg
    

    I created a report with that table as the Record Source, dropped the [ImageLocation] field onto the Detail band, and added an Image control. I used the following as the On Format event of the report's Detail section:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
        Me.ImageControl.Picture = Me.ImageLocation.Value
    End Sub
    

    When I print the report I see the images associated with the filenames in the table.

    Edit re: comment

    Newer versions of Access (since at least Access 2010) do not need the On Format VBA code. We can simply place an Image control on the report and set its Control Source property to the (text) field containing the path to the image file. Thanks to Albert D. Kallal for the tip!

    0 讨论(0)
提交回复
热议问题