Mike-palmer
Registered User.
- Local time
- Today, 19:43
- 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?
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?