Storing picture and viewing picture

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Josephbupe
    New Member
    • Jan 2008
    • 7

    Storing picture and viewing picture

    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]
    Last edited by Stewart Ross; Apr 9 '08, 10:03 AM. Reason: added code tags to VB code
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    Hi
    Part of your subroutine will need to save the path to the picture into a table.

    Then you will need to add code to the form_load event that reads the path that you stored earlier and then sets the picture property of the image to that, just like you have in your code here

    Comment

    Working...