运行VBA code在MS Access报告当openned没有preVIEW印刷 [英] Running VBA code in MS Access report when it is openned without preview for printing

查看:198
本文介绍了运行VBA code在MS Access报告当openned没有preVIEW印刷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面code打印MS Access报表,而无需打开它preVIEW。 不过,我想运行一些code,当用户选择打印修改的报告。

The below code prints a MS Access Report without opening it for preview. However, I would like to run some code to modify the report when a user selects to print it.

DoCmd.OpenReport RptName, , , "[ItemNumber]= " & Me.ItemNum

我已经尝试了关于启动,开开和第事件,但他们没有运行code,我在那里的地方。

I have tried the "On Activate", "On Open", and "On Page" events but none of them run the code that I place in there.

每个ItemNumber具有与之相关联的图像。每当他们打的打印按钮上面的code运行发送itemNumber他们希望印在那一刻,我想插入相应的无界图像在报告上打印。

Each ItemNumber has an image associated with it. Whenever they hit the print button the above code runs sending the itemNumber they would like printed and at that moment I would like to insert the appropriate unbounded image to print on the report.

推荐答案

把你的code在节的格式事件。假设你有一个名为 Image1的在报表的详细信息部分图像控制:

Put your code in the Format event of the Detail section. Assuming you have an image control named Image1 in the detail section of your report:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me.Image1.Picture = DLookup("ImagePath", "ImageTable", _
                                "ItemNumber=" & Me.ItemNum)
End Sub

这篇关于运行VBA code在MS Access报告当openned没有preVIEW印刷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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