I am trying to adopt the code below to store a picture file in a table filed so that i can view it any time i open the form with its control. However, this code did not do that. When i loaded the picture quite well its path was saved in the table field but after i close the form and reopen it i could not see the picture. How can i always make the picture viewable.
The form name is frmComment
The table has two fields: ItemID and PicFile
[code=vb]---------------
Private Sub cmdAddPicture_C lick()
Dim OFN As OPENFILENAME
On Error GoTo Err_cmdAddPictu re_Click
' Set options for dialog box.
With OFN
.lpstrTitle = "Images"
If Not IsNull([PicFile]) Then .lpstrFile = [PicFile]
.flags = &H1804 ' OFN_FileMustExi st + OFN_PathMustExi st + OFN_HideReadOnl y
.lpstrFilter = MakeFilterStrin g("Image files (*.bmp;*.gif;*. jpg;*.wmf)", "*.bmp;*.gif;*. jpg;*.wmf", _
"All files (*.*)", "*.*")
End With
If OpenDialog(OFN) Then
[PicFile] = OFN.lpstrFile
Forms!frmCommen t![imgPicture].Picture = [PicFile]
SysCmd acSysCmdSetStat us, "Afbeelding : '" & [PicFile] & "'."
End If
Exit Sub
Err_cmdAddPictu re_Click:
MsgBox Err.Description , vbExclamation
End Sub[/code]
The form name is frmComment
The table has two fields: ItemID and PicFile
[code=vb]---------------
Private Sub cmdAddPicture_C lick()
Dim OFN As OPENFILENAME
On Error GoTo Err_cmdAddPictu re_Click
' Set options for dialog box.
With OFN
.lpstrTitle = "Images"
If Not IsNull([PicFile]) Then .lpstrFile = [PicFile]
.flags = &H1804 ' OFN_FileMustExi st + OFN_PathMustExi st + OFN_HideReadOnl y
.lpstrFilter = MakeFilterStrin g("Image files (*.bmp;*.gif;*. jpg;*.wmf)", "*.bmp;*.gif;*. jpg;*.wmf", _
"All files (*.*)", "*.*")
End With
If OpenDialog(OFN) Then
[PicFile] = OFN.lpstrFile
Forms!frmCommen t![imgPicture].Picture = [PicFile]
SysCmd acSysCmdSetStat us, "Afbeelding : '" & [PicFile] & "'."
End If
Exit Sub
Err_cmdAddPictu re_Click:
MsgBox Err.Description , vbExclamation
End Sub[/code]
Comment