运行VBA code在MS Access报告当openned没有preVIEW印刷报告、MS、VBA、code

2023-09-09 21:23:40 作者:妞、别跟爷拽

下面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
 
精彩推荐
图片推荐