Store and retrieve image in Access database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • THEAF
    New Member
    • Mar 2007
    • 52

    Store and retrieve image in Access database

    I have a form for staff details, the details come from Access and i am using this piece of code for my List box:

    Code:
    Private Sub lstRecord_Click()
        rsMyRS.FindFirst " StaffID =" & Str(Split(lstRecord.List(lstRecord.ListIndex), vbTab)(1))
        
        txtStaffid.Text = rsMyRS!StaffID
        txtFname.Text = rsMyRS!Firstname
        txtSname.Text = rsMyRS!Lastname
        txtDate.Text = rsMyRS!Date
        txtDob.Text = rsMyRS!DOB
        txtAddress.Text = rsMyRS!Address
        txtCtown.Text = rsMyRS!City_Town
        txtPcode.Text = rsMyRS!Postcode
        txtTel.Text = rsMyRS!Tel
        txtMob.Text = rsMyRS!Mobile
        txtEmail.Text = rsMyRS!Email
        txtPreocc.Text = rsMyRS!Preocc
        txtNote.Text = rsMyRS!Note
        optTemp.Value = rsMyRS!Temporary
        optPermin.Value = rsMyRS!Permanent
    End Sub
    what i wana do is add a picture box to my form. So when I click on a different name or the StaffId in the listbox, that staffs picture should show up.

    Can you please tell me how to do this and what i will need to do on Access to enable this to happen.
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    #2
    access DB with staff name/id etc and a file path to the picture.

    then when a user clicks the id field etc, run a query which selects the path associated with that id number and dumps the path into the picture box url...

    im sure this will work

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      BTW how you have stored the image in access database ?

      Is it file path or the file itself ?

      Comment

      • THEAF
        New Member
        • Mar 2007
        • 52

        #4
        to reply to the first one as i am new to coding i don;t have much knowledge of queries and such so that will be difficult for me and to the second one I was thinking of using OLE Object as datatype and then insert the object into the place.

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          Originally posted by THEAF
          I was thinking of using OLE Object as datatype and then insert the object into the place.
          That is the best thing to do.

          You can find related articles in the articles section if VB.

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Actually, there has been a big discussion here recently about the best way to store and retrieve images in a database. I think you'll find it in the HowTo's area, but it may still be in Editor's Corner. Anyway, do a search on something like "BLOB image database" and you should find it.

            Comment

            Working...