relative link for background image in report (1 Viewer)

groengoen

Registered User.
Local time
Today, 18:05
Joined
Oct 22, 2005
Messages
141
I have a report with a background image (watermark).

I have made it a linked image as it makes the report very large. I would like to make the link to the image relative to the current location of the database, rather than an absolute location link. Is this possible?

This would enable distribution of the database to other users, as a complete package.

When I tried a relative location eg. backgrounds\image.jpg I get a message that access "can't open the file". If I use the absolute location, eg. c:\Documents and Settings\.....\backgrounds\image.jpg it works ok.
 

khawar

AWF VIP
Local time
Today, 21:05
Joined
Oct 28, 2006
Messages
870
You can assign path in vba on the onOpen event of the report
 

groengoen

Registered User.
Local time
Today, 18:05
Joined
Oct 22, 2005
Messages
141
Thanks, that is handy. Is it possible to assign the path to the current directory, without specifically giving the path, because I wouldn't know which directory my users would be putting the .mdb file.

Geoff
 

khawar

AWF VIP
Local time
Today, 21:05
Joined
Oct 28, 2006
Messages
870
Use this code on open event of report

Code:
Dim PicturePath as String

PicturePath = left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\", -1, vbTextCompare)) & "\MyPicture.jpg"

me.image0.picture = PicturePath

replace Mypicture.jpg with your picture name
replace image0 with Image control name on report
 

Users who are viewing this thread

Top Bottom