Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
590 views
in Technique[技术] by (71.8m points)

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

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 server. The VBScript creates a unique folder based on date/time...the folder location of each image name is written to the database as one of the fields in UNC pathfilename.jpg notation.

I have a primary database and the transaction (images) are referenced in the second database. I have created a relationship as well... I am able to build my report in Access from data from both the tables, however, I'd like to automate a print job that grabs the last entry to the primary database, it's associated images (up to 10...but not 10 in every case) and print them out. When I try to build the report I cannot figure out how to use a query result of the field with the filenames to display on the report.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

ImageLocation                           
-----------------------------------
\SERVERPublicPicturesimage1.jpg        
\SERVERPublicPicturesimage2.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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...