Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Picture to change on report depending on the query

Status
Not open for further replies.

NC1977

Programmer
Nov 26, 2007
22
CA
Hi,

i have a report with a map on it. This report is run when the user selects a location. I would like that on my report, whatever location the user selects, theirs a picture of the map.. The picture would change everytime their is a location change.

Can this be done?
 
You can set the Picture property of an image control to whatever file name you want in the On Format event of the section of the report containing the image control.

Do you have your file names stored in a table some place?

Duane MS Access MVP
Now help me support United Cerebral Palsy
 
Hi dhookom!

I created a table with the picture names in it. They are all located in a folder on my computer...The picture needs to load in the report for the location the user has selected...I'm not sure where the On Format is for a report???
 
Does your "table with the picture names" have any value that ties to the record source of your report?

To find properties, view the property dialog while in design view. Click the section of the report containing the image control. View the Event properties in the dialog and find the On Format event. You will need to add code in the Code Builder so the event property will actually read:
[Event Procedure]


Duane MS Access MVP
Now help me support United Cerebral Palsy
 
ok, I've linked my table with the picture names to my query. I've found the on format so that I can add code. I now don't know what code to put??
 
Add a text box to your report's section containing the image control.
Name: txtFileNameField
Control Source: [FileNameField]
Visible: No

Then add code to look like the following where imgImageCtrl is the name of your image control.
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me.imgImageCtrl.Picture = Me.txtFileNameField
End Sub

Duane MS Access MVP
Now help me support United Cerebral Palsy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top