title: Creating a Document Database using Microsoft Access
body: <p>I am attempting to create a table within a database which store all of the documents related to the database "in it".  What I really want to do is have a file uploaded and have vba code which copies the file to a network location, renames the file by concatenating two fields from the document table form (eliminating the issue of duplicate file names in the external location), and then stores the file name and file path in a file path field in the table.  I am very new to access and vba so I am having difficulty getting everything to work.  The code I currently have is below:</p>
  
  <pre><code>Option Compare Database
  
  Private Sub Command15_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
      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>
  
  <p>I can not seem to get a handle on how to move, rename by concatenating the two fields from the form, or store the path in the path field of the table.  I have been to the following locations to obtain what information I could</p>
  
  <p><a href="https://stackoverflow.com/questions/14915179/ms-access-browse-for-file-and-get-file-name-and-path">ms access browse for file and get file name and path</a></p>
  
  <p><a href="https://stackoverflow.com/questions/16943003/vba-to-copy-a-file-from-one-directory-to-another">VBA to copy a file from one directory to another</a></p>
  
  <p>I am currently using Microsoft Access 2010, and I do not wish to use the file attachment field type because of database size constraints.  Currently I press a button and a file explorer appears to navigate to the file being uploaded, and the path and file name are entered into strings.  After this point I am lost.  If any other information is needed please let me know.  Thanks in advance for the assistance.</p>