0
votes

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

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

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.

1
What exactly are you trying to modify on the report? Some report properties can only be modified in Design view.mwolfe02
Thanks for answering mwolfe's question in your edit. As I understand it, you want an image object to have a dynamic source?PowerUser

1 Answers

3
votes

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