VBA code to upload a document to a FORM prior to saving

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • benny1983
    New Member
    • Oct 2014
    • 25

    VBA code to upload a document to a FORM prior to saving

    I have a form which we use for data entry and sometimes we need to upload a document to keep with a record.

    I have made a section for attachments in the table for storing these. What I'm after is some VBA code so when I click a button on the form I am using with the data entry, I can select a file to attach to this record. The catch here is that the record may not have been saved yet so i really need it to sit on the form until we are finished data entry then save this all as one record.

    I wouldn't know where to start with this so have also looked at possibly storing the file path in a text box then once we submit the form some sort of code to attach the file (recorded in that file fath) to the attachment in the table.

    Any help would be greatly appreciated. I have searched many threads and forums but nothing straight forward.
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    Depending on what version of Access you are using, you may or may not have the option to add a field to your table with a hyperlink datatype. If you do have this option, then you would have the ability to do a drag-n-drop with the file onto the textbox that is bound to this field. Are you wanting to be able to open the attachment from within the database? What type of files are these attachments? PDFs, Word docs, etc?

    Comment

    • benny1983
      New Member
      • Oct 2014
      • 25

      #3
      Thanks for the reply - I was worried no one would have a fix.

      I am running Access 2010.

      Yes I'd like to be able to open the attachments from within the database when required.

      The file attachements are Word Docs.

      Happy to give anything a shot, just haven't done the attachment thing before but want it to be user friendly so need to be able to enter the attachment from the form.

      I dont want users accessing the back end of the database.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        I strongly advise against storing the document within the database.
        I understand that this is an option; however, it leads to bloat and the field is not universally supported should you need to upgrade. Worse, if the database corrupts, you lose all of your documents!
        Instead, use the method that Seth is proposing where the link to the document's location on the pc/network is stored in the table.

        Comment

        Working...