Images in Forms and Reports

M

MortOnSafari

G'day all,

I have used info from MS Knowledge Base Article 210100 to
link images into a report and form, with the images
residing in the same folder as the database as per the
section 'Storing the Image in a Relative path'.
However, I would like to have the path go to a 'Photos'
folder that resides in the same folder as the DB eg. have
the DB in C:\work and the Photos in C:\work\Photos.
Can anyone tell me how to adjust the code which trims off
the FullName.
many thanks from a little Aussie Battler. . . .
 
J

JulieD

G'day (from Perth, WA)

i'm assuming the code you're talking about is this one ...

Function setImagePath()
Dim strImagePath As String
Dim strMDBPath As String
Dim intSlashLoc As String

On Error Goto PictureNotAvailable
'Obtain the full path of the current database or Access Project
strMDBPath = CurrentProject.FullName

'Find the location of the last backslash
intSlashLoc = InStrRev(strMDBPath, "\", Len(strMDBPath))

'Trim off the database name, leaving the path
'and append the name of the image file
strImagePath = Left(strMDBPath, intSlashLoc) & _
Me.txtImageName

'Set ImageFrame to the path of the image file
Me.ImageFrame.Picture = strImagePath
Exit Function
PictureNotAvailable:
strImagePath = "NoPicture.BMP"
Me.ImageFrame.Picture = strImagePath

End Function

********
if so edit the section
'Trim off the database name, leaving the path
'and append the name of the image file
strImagePath = Left(strMDBPath, intSlashLoc) & _
Me.txtImageName

to read

'Trim off the database name, leaving the path
'and append the name of the image file
strImagePath = Left(strMDBPath, intSlashLoc) & "photos\" & _
Me.txtImageName

Hope this helps

Cheers
JulieD
 
B

Boris

JulieD said:
[...]
On Error Goto PictureNotAvailable
'Obtain the full path of the current database or Access Project
strMDBPath = CurrentProject.FullName

'Find the location of the last backslash
intSlashLoc = InStrRev(strMDBPath, "\", Len(strMDBPath))

'Trim off the database name, leaving the path
'and append the name of the image file
strImagePath = Left(strMDBPath, intSlashLoc) & _
Me.txtImageName

Or use CurrentProject.Path instead of above code to retrieve the path of the
current database directly.

Boris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top