title: MSAccess VBA to Save a Single Attachment to a Folder
body: <p>I'm really new to Access so I haven't heard of most of the commands for Access VBA, but I am pretty familiar with Excel VBA.</p>
  
  <p>What I'm trying to do is save the attachment that was just entered into a table through a form. I've been looking at some examples online and trying to get it to work for me but the code is not moving the file to the folder. I do not get a debug error though.</p>
  
  <p>Here is my current code. I know it is set to loop right now, where really I just want the last attachment in the table each time, but I don't know how to get only the last attachment. Either way, this current code doesn't move ANY attachments.</p>
  
  <pre><code>Private Sub cmdAddRecord_Click()
  
  If MsgBox("Adding a new record will save the current form. You will not be able to edit this credit request. Would you like to continue?", vbQuestion + vbYesNo, "Save current record and open new form") = vbYes Then
  
  MkDir "C:\Users\username\Desktop\IC Transfer Back Up Attachments\" &amp; Me.txtRequestID &amp; "-" &amp; "Back Up Attachments" &amp; " " &amp; Format(Date, "MMDDYY")
  
  DoCmd.RunCommand acCmdSaveRecord
  
  Dim SaveFolder As String
  SaveFolder = "C:\Users\username\Desktop\IC Transfer Back Up Attachments\" &amp; Me.txtRequestID &amp; "-" &amp; "Back Up Attachments" &amp; " " &amp; Format(Date, "MMDDYY")
  
  Dim rsParent As DAO.Recordset2
  Dim rsChild As DAO.Recordset2
  Set rsParent = CurrentDb.OpenRecordset("SELECT * FROM tblICTRequested")
  Set rsChild = rsParent.Fields("BackUpAttachments").Value
  
  Do Until rsChild.EOF
      rsChild.Fields("FileData").SaveToFile SaveFolder
      rsChild.MoveNext
  Loop
  
      DoCmd.RunCommand acCmdCloseWindow
      DoCmd.OpenForm "frmICTRequested"
  
  End If
  End Sub
  </code></pre>
  
  <p>Most of this seems to make sense to me, but I'm not sure what I should put in the <code>.Fields("FileData").SaveToFile</code> line, since I don't have a field named "FileData" but I've tried all my existing fields to no avail.</p>
  
  <p>For reference, here are some of the online links I have reviewed:</p>
  
  <p><a href="https://www.experts-exchange.com/questions/29005769/MS-Access-attachment-file.html" rel="nofollow noreferrer">https://www.experts-exchange.com/questions/29005769/MS-Access-attachment-file.html</a>
  <a href="https://msdn.microsoft.com/en-us/library/office/ff191852.aspx" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/office/ff191852.aspx</a>
  <a href="https://access-programmers.co.uk/forums/showthread.php?t=282135" rel="nofollow noreferrer">https://access-programmers.co.uk/forums/showthread.php?t=282135</a></p>
  
  <p>Any tips? Much appreciated!</p>