Changing header image on report (1 Viewer)

Design by Sue

Registered User.
Local time
Today, 15:11
Joined
Jul 16, 2010
Messages
653
I have a database used for several product lines. Depending on the product line selected, I need to add an image to my report as the header for it. I need to store the images (there are only 3) in the database and cannot have an external link to them. Have been trying to figure out the best way to do this and I am finding both OLE Objects and Image Objects. What is the opinion of the masses on how to accomplish this?

Sue
 

llkhoutx

Registered User.
Local time
Today, 17:11
Joined
Feb 26, 2001
Messages
4,018
Use the form header "OnFormat" event to programmatically set a "header control" control source value.
 

Design by Sue

Registered User.
Local time
Today, 15:11
Joined
Jul 16, 2010
Messages
653
I will try that tomorrow morning, thanks.

I was hoping someone could give me some insight on how to actually code this. I am thinking of using a DLoopUp basically as stated below:

OleObject = DLookup ("Image", "HeaderTBL", "Brand= 'SelectedBrand'")

where SelectedBrand will refer to the table that indicates the selected brand (That table has 2 fields, brand and include, in which the include is a yes/no and if the brand is selected the field is yes and all others are no).

Would this be the correct way to code this?

Would this work in the onformat event?

Can someone comment on this thought or point me in a better (more correct) direction?

Thanks
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:11
Joined
Feb 19, 2013
Messages
16,635
why not include the image in your form recordsource?
 

Design by Sue

Registered User.
Local time
Today, 15:11
Joined
Jul 16, 2010
Messages
653
Thanks - but this is a report not a form (though I believe your comment - and that of llk - also applies to forms.) Again my problem is not as much where to put the code but what code to use. Please help if you can.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:11
Joined
Feb 19, 2013
Messages
16,635
if you include in your recordsource, you just need to use an image control and bind it to the field
 

Design by Sue

Registered User.
Local time
Today, 15:11
Joined
Jul 16, 2010
Messages
653
Thanks for your trying to help me but I just don't understand what the process is here. I need to save the images within the database - in a table. I need to assign one of the headers to a report based on a selection made of the brand. The table with the images, has a field "brand" and the selected table had the field "brand" and a yes/no field indicating which is the selected brand - only one brand is selected at any time. How would I write the code to assign the image from the field in the table?

Sue
 

CJ_London

Super Moderator
Staff member
Local time
Today, 23:11
Joined
Feb 19, 2013
Messages
16,635
lets say the recordsource to your form is

Code:
 SELECT tblData.* 
 FROM tblData
And your images are stored in a table called HeaderTBL

rewrite your recordsource as follows
Code:
 SELECT tblData.*, HeaderTBL.image 
 FROM tblData, HeaderTBL
 WHERE HeaderTBL.Brand='SelectedBrand'

Now in your report header, simply have an image control where the controlsource is Image

Note: If SelectedBrand is the value of a field in tblData then the WHERE bit becomes

WHERE HeaderTBL.Brand=tblData.Brand
 

smig

Registered User.
Local time
Tomorrow, 01:11
Joined
Nov 25, 2009
Messages
2,209
if you only have 3 images to select from you can put all of them on the report and hide the ones you don't want to show.
 

Users who are viewing this thread

Top Bottom