Storing the image in a relative path

G

Guest

As far as pictures are concerned, thank you for all your help; I finally made
it. Paths to pictures on hard drive instead of storing them in the actual
data base;
but the problem is that for errors when NoPicture.bmp should appear I get
the following error meessage:
The expresiion OnFormat you entered as the event property setting produced
the following error: Microsoft Access can't open the file "NoPicture.bmp".

Following is the code I entered :

Function setImagePath()

Dim strImagePath As String
Dim strMDBPath As String
Dim intSlashLoc As String

On Error GoTo PictureNotAvailable
strMDBPath = CurrentProject.FullName
intSlashLoc = InStrRev(strMDBPath, "\", Len(strMDBPath))
strImagePath = Left(strMDBPath, intSlashLoc) & Me.txtImageName
Me.ImageFrame.Picture = strImagePath

Exit Function


PictureNotAvailable:
strImagePath = "NoPicture.bmp"
Me.ImageFrame.Picture = strImagePath


End Function




All pictures including NoPicutre.bmp are in the same folder. All of them
work but NoPicture.bmp


Thank you for you help in advance
 
A

Albert D. Kallal

You still need to supply the path name to your nopicture.bmp.

You can use:
PictureNotAvailable:
strImagePath = currentproject.Path & "\NoPicture.bmp"
Me.ImageFrame.Picture = strImagePath

And, note the use of currentproject.Path, which you can use in your other
routine also...
 

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