How to add an image to a field in a table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    How to add an image to a field in a table

    I would like to lookup an image from my pc and add it to a specific field in a form.
    form name: AddSignaturesF
    table: tblImageOLEs
    field:signature 1 (OLE object field)
    I found this code from "Adezi" from an old post and needs to make more changes to it.
    It finds the image, but does not add it to the "signature1 " field
    Code:
    Dim varItem As Variant
    
    With Application.FileDialog(msoFileDialogFilePicker)
       With .Filters
         .clear
       .add "Bitmap Files", "*.bmp"
         .add "JPEG Files", "*.jpg"
         .add "Graphic Interchange Format Files", "*.gif"
       End With
                  .AllowMultiSelect = False
           .FilterIndex = 1
           .ButtonName = "Select Graphic"
           .InitialFileName = vbNullString
           .InitialView = msoFileDialogViewDetails
           .Title = "Load Graphic File!"
              If .Show Then
             Me.Signature1 = .SelectedItems(1)
              End If
    End With
    Any suggestions please. I am pleading stupid here
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    It is a little mor4e complicated that that. Assuming that Signature1 is a 'Bound Object Frame' whose Control Source is an OLE Object Field in a Table, then:
    Code:
    Dim varItem As Variant
    
    With Application.FileDialog(msoFileDialogFilePicker)
      With .Filters
        .Clear
          .Add "Bitmap Files", "*.bmp"
          .Add "JPEG Files", "*.jpg"
          .Add "Graphic Interchange Format Files", "*.gif"
      End With
        .AllowMultiSelect = False
        .FilterIndex = 1
        .ButtonName = "Select Graphic"
        .InitialFileName = vbNullString
        .InitialView = msoFileDialogViewDetails
        .Title = "Load Graphic File!"
           If .Show Then
             With Me.Signature2
               .OLETypeAllowed = acOLEEmbedded
               .SourceDoc = Application.FileDialog(msoFileDialogFilePicker).SelectedItems(1)
               .Action = acOLECreateEmbed
             End With
           End If
    End With

    Comment

    • neelsfer
      Contributor
      • Oct 2010
      • 547

      #3
      thx Adezi for the effort. Its almost 100%.
      The code copies the image into the signature1 field as required, but it is shown as an icon together with the file name. Is there perhaps a setting to be changed on the pc, to display the pic "live" as you open the form?
      my purpose - In this instance the person capturing the order, compares the signature of the authorized person on the system, to the person that signed the order off.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        Your last post there reminded me about another old thread that covers part of this: Display dynamic image in MS Access 2007
        If you are using V2007 or V2010 then you should be ready to rock-n-roll. I've been using this for the past few months and it is sooooooo much easier than what I had to do in V2003.

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Set the DisplayType Property of the Unbound Object Frame to 'Content'.

          Comment

          Working...