Handling relative filenames in the DB

Mike-palmer

Registered User.
Local time
Today, 17:58
Joined
Mar 27, 2003
Messages
37
I have a DVD database that uses a seperate directory to contain the DVD over images. The user chooses the image for a particular DVD using the following code:

Private Sub imgPicture_DblClick(Cancel As Integer)
Dim OFN As OPENFILENAME
On Error GoTo Err_cmdInsertPic_Click

' Set options for dialog box.
With OFN
.lpstrTitle = "Images"
If Not IsNull([PicFile]) Then .lpstrFile = [PicFile]
.flags = &H1804 ' OFN_FileMustExist + OFN_PathMustExist + OFN_HideReadOnly
.lpstrFilter = MakeFilterString("Image files (*.bmp;*.gif;*.jpg;*.wmf)", "*.bmp;*.gif;*.jpg;*.wmf", _
"All files (*.*)", "*.*")
End With

If OpenDialog(OFN) Then
[PicFile] = OFN.lpstrFile
[imgPicture].Picture = [PicFile]
SysCmd acSysCmdSetStatus, "Afbeelding: '" & [PicFile] & "'."
End If
Exit Sub

Err_cmdInsertPic_Click:
MsgBox Err.Description, vbExclamation
End Sub


The problem is this puts the full pathname of the target file in the database which means the database has to be fixed in one place. I know I could write some code to remove the front part of the path and stick it back when I need it, but is there an easier way?
 
Not really. You were right to suggest stripping the path from the file location and just storing the File Name. It may be a good time to develop a robust file structure that you can ship/export with the Db for the storage of such images.

You can then have a standard way of displaying the images by extracting the Db path and adding on your file structure to obtain the file. eg

YourDbPath/Images/ImageFile.jpg
 

Users who are viewing this thread

Back
Top Bottom