title: Saving Image as OLE Object, in Access
body: <p>I have a table with a field that is of type OLE Object.  I then have a form with a number of fields.  Some are just text fields.  But, I also have an Image object on the form.  When a user clicks a button, a dialog opens and they can pic a photo.  Once they select the photo, the Image object displays that picture.  I want to save that image to database.  What I have only seems to save a reference to where the file is located, on the computer.  So, this would not work if the db is moved.  Here is the code I have:</p>
  <pre><code>Dim wrkCurrent As DAO.Workspace
  Dim dbs As DAO.Database
  Dim rstPerson As DAO.Recordset
  
  Set wrkCurrent = DBEngine.Workspaces(0)
  Set dbs = CurrentDb
  Set rstPerson = dbs.OpenRecordset(&quot;SELECT * FROM tbl_person WHERE id =&quot; &amp; ID)
  
  With rstPerson
   .Edit
        !bio_photo = Me.Image37.picture
   .Update
  End With
  </code></pre>
  <p>How would I save the image file to the OLE Field, so that I could load it back to the Image object, on the form, at a later time?</p>
  <p>Thanks</p>
  <p><strong>Answer:</strong></p>
  <p>So, what I ended up doing was following this <a href="https://support.microsoft.com/en-us/kb/210486" rel="nofollow noreferrer">https://support.microsoft.com/en-us/kb/210486</a> [EDIT: that link is now dead, try <a href="https://mskb.pkisolutions.com/kb/210486" rel="nofollow noreferrer">this</a> instead]</p>
  <p>I use the readBLOB function to read the file and save it into the database.  Then, when I run a report or open a form that has the picture, onload, I use the WriteBlob function to write the file to a temp folder and then use that path to populate an Image object.</p>