Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2007
    Posts
    225

    Question Unanswered: Attachment Field Auto Renamig Files

    Hello All,

    I have an attachment field in access 2016 which allows me to attach documents to each record. I was wondering if there is a way to code the attachment field so that it automatically assigns a file name to the attachment, regardless of what the file's name already is. Basically, I'm running into a problem that some files have the same name, and it keeps prompting me that I have to rename it anyway. It would be great if access could assign a name, and add a trailing number or something so that I can add multiple attachments without having to rename them.

    Also, how do I figure out where access is storing these attachments?


    Thanks so much!

  2. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    630
    Provided Answers: 35
    it stores them in the attachment field. This field is a recordset.

    you can assign the filename with a datestamp as name, then attach it.

    vSrc = "c:\folder\filename.xls"
    vTarg = vSrc & Format(Now,"yymmdd-hhnnss") & ".xls"
    name vSrc as vTarg

    'attach file here

  3. #3
    Join Date
    Oct 2007
    Posts
    225
    Quote Originally Posted by ranman256 View Post
    it stores them in the attachment field. This field is a recordset.

    you can assign the filename with a datestamp as name, then attach it.

    vSrc = "c:\folder\filename.xls"
    vTarg = vSrc & Format(Now,"yymmdd-hhnnss") & ".xls"
    name vSrc as vTarg

    'attach file here

    Where would that code go? In the double click event? I'm new to working with the attachment field. Also, I keep hearing that the attachments will bog down the data base and should be stored elsewhere. What is the best way to go about doing that? Thanks!

  4. #4
    weejas is offline Grumpy old man (training)
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    1,105
    Provided Answers: 18
    If you don't want to store the files in the database, then the best way would be to request a section of the network be made available to all database users, and store the path to the files in the database. You could then generate the required file names and save the files as these names, so that you avoid clashes.
    10% of magic is knowing something that no-one else does. The rest is misdirection.
    Beers earned: 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •