Images in Forms and Reports

  • Thread starter Thread starter MortOnSafari
  • Start date Start date
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. . . .
 
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
 
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
 
Back
Top