创建一个报告,该报告将显示表中文件名中的许多图像 [英] Creating a report that will display a number of images from filenames in a table

查看:111
本文介绍了创建一个报告,该报告将显示表中文件名中的许多图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VBScript,可用来读取XML文件并在Access 2010中填充几个表.VBScript还将jpg文件从读卡器复制到服务器上的某个位置. VBScript根据日期/时间创建一个唯一的文件夹...每个图像名称的文件夹位置作为UNC path\filename.jpg表示法中的字段之一写入数据库.

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 path\filename.jpg notation.

我有一个主数据库,并且在第二个数据库中引用了事务(图像).我也建立了关系... 我可以使用两个表中的数据在Access中建立报告,但是,我想自动执行一个打印作业,该作业将获取主数据库的最后一个条目,它是关联的图像(最多10个...但不是10个)在每种情况下)并打印出来.当我尝试生成报告时,我不知道如何使用带有文件名的字段的查询结果显示在报告中.

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.

推荐答案

您可以使用Image控件和一行VBA代码来完成您描述的操作.对于名为[ImageLocations]的示例表

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

我创建了一个以该表为Record Source的报告,将[ImageLocation]字段放到了Detail区域中,并添加了一个Image控件.我将以下内容用作报告的详细信息"部分的On Format事件:

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.

较新版本的Access(至少从Access 2010开始)不需要On Format VBA代码.我们可以简单地在报表上放置一个Image控件,并将其Control Source属性设置为包含图像文件路径的(text)字段.感谢Albert D. Kallal的提示!

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!

这篇关于创建一个报告,该报告将显示表中文件名中的许多图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆