Results 1 to 3 of 3
  1. #1
    RE_ is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2022
    Posts
    23

    Add windows user name to exported file

    Hi all,

    I'm using the below to export a query:



    Private Sub Form_Close()
    Dim sFilename As String
    sFilename = "path\data_dump.csv"
    DoCmd.TransferText acExportDelim, , "data_dump", sFilename, True
    End Sub

    How can I dynamically add the to the file name "data_dump.csv" the windows user name of the user that is actually running the above? Something like "user1_data_dump.csv". If someone else runs the above it could be "user4_data_dump.csv".

    Thanks!!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Can use Environ("USERNAME") to pull Windows login username.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    RE_ is offline Novice
    Windows 10 Office 365
    Join Date
    Mar 2022
    Posts
    23
    great, thanks June7!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 08-07-2019, 02:57 PM
  2. Replies: 4
    Last Post: 10-29-2016, 12:20 AM
  3. Adding Date to exported file not quite right
    By coach32 in forum Programming
    Replies: 5
    Last Post: 08-08-2016, 06:15 PM
  4. Formatting exported CSV file
    By oatsybob in forum Programming
    Replies: 3
    Last Post: 02-04-2013, 11:32 PM
  5. to open Exported Excel File
    By waqas in forum Programming
    Replies: 3
    Last Post: 10-16-2011, 12:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums