title: Copy and rename a file
body: <p>I have an Access Data Base (Backend). The size is increasing dramatically, and I am sure is because of an attachment field I have in my master table.</p>
  
  <p>I decided to store the file path name and not the file itself;<br>
  I found here @Fionnuala, this VBA routine and function that would work perfect for me (I just changed AllowMultiSelect to FALSE). </p>
  
  <p>How do I copy the selected file to a network folder and then rename it with the field ID as part of the name. like  [ID] &amp; “lto.pdf”</p>
  
  <p>ID is a field  in my master table;<br>
  The file name after copied would br i.e. <strong>O:/DOCS/678LTO.PDF</strong></p>
  
  <pre><code>Private Sub Command7_Click()
  
  Dim f As Object
  
  Set f = Application.FileDialog(3)
  
  f.AllowMultiSelect = FALSE
  
  If f.Show Then
      For i = 1 To f.SelectedItems.Count
          sFile = Filename(f.SelectedItems(i), sPath)
          MsgBox sPath &amp; "---" &amp; sFile
  
  'Here I need to copy the file to O:\DOCS
  'And rename it as [ID] &amp; “lto.pdf” resulting O:\DOCS\328LTO.pdf
  
      Next
  End If
  
  End Sub
  
  
  Public Function Filename(ByVal strPath As String, sPath) As String
      sPath = Left(strPath, InStrRev(strPath, "\"))
      Filename = Mid(strPath, InStrRev(strPath, "\") + 1)
  End Function
  </code></pre>