Here are three different implementations of a function that returns the full path to an 'Images' subdirectory
of the directory containing the mdb file.
The last version works in all Access versions from 97, the others may be restricted to more recent versions.
Watch for line-wrap !
Private Function GetImageFolder() As String
GetImageFolder = Left$(CurrentDb.Name, Len(CurrentDb.Name) - Len(Dir$(CurrentDb.Name))) & "Images\"
End Function
Private Function GetImageFolder() As String
Dim DBFullPath As String
DBFullPath = CurrentDb().Name
GetImageFolder = Left(DBFullPath, InStrRev(DBFullPath, "\", Len(DBFullPath))) & "Images\"
End Function
Private Function GetImageFolder() As String
Dim DBFullPath As String
Dim I As Integer
DBFullPath = CurrentDb().Name
' Strip the filename from the full path
For I = 1 To Len(DBFullPath)
If Mid(DBFullPath, I, 1) = "\" Then
GetImageFolder = Left(DBFullPath, I) & "Images\"
End If
Next
End Function
--
_______________________________________________________
http://www.ammara.com/
Image Handling Components, Samples, Solutions and Info
DBPix 2.0 - lossless jpeg rotation, EXIF, asynchronous
=?Utf-8?B?Vy4gTGluZG5lcg==?= said:
I would like to distribute an access image DB an CD, so I cannot use abolute paths like X:\image or \\server\image
to the image, because these paths are different for every user. If I use relative Paths \image from the
DB file to the images, then the images are not displayed. How can I use relative paths?