Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    2000 (Help with export)

    I have the code attached that works on a command button to export a query to a txt file. However what I don't want is that if that txt file already exists for it to be overwritten. Is there a way of putting in the code to ammend the file name to add a r1, r2 to the text file name?
    Attached Files Attached Files
    Best Regards,

    Luke

  2. #2
    Star Lounger
    Join Date
    Sep 2002
    Location
    Hastings, Sussex, England
    Posts
    67
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: 2000 (Help with export)

    Luke,

    I haven't got a direct answer immediately, but can offer an alternative approach. What about adding the date and time to the filename, e.g.
    strFilename = "myfile " & Format(Now(), "yyyy-mm-dd") & " " & Format(Now(), "hhmmss") & ".xls"
    DoCmd.OutputTo acOutputQuery, "qryMyQueryName", acFormatXLS, strFilename, True
    This makes every file name unique.

    Just a thought.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: 2000 (Help with export)

    That is a good idea. You can combine the date and time in one format:

    strFilename = "myfile " & Format(Now, "yyyy-mm-dd hhnnss") & ".xls"

  4. #4
    4 Star Lounger
    Join Date
    Mar 2005
    Location
    Leicestershire, United Kingdom
    Posts
    506
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: 2000 (Help with export)

    Sounds a cracking idea!

    Many thanks for your assistance.
    Best Regards,

    Luke

Posting Permissions

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