Save using Current Date and Current user profile

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MattFitzgerald
    New Member
    • Jul 2007
    • 30

    Save using Current Date and Current user profile

    Hi hope some one can help I have 2 questions:-

    Question 1) When saving a file in access to excel how do I specify current date

    Question2) When saving a file in access to excel how do I specify current user profile

    To be more specific I have a Macro in MS Access and I have selected Action "Output to"

    The Output file is currently set to:-

    C:\Documents and Settings\Fitzge m4\Desktop\Cadb uryData_Date

    I want to replace Fitzgem4 with Current User and Date with Todays Date

    The output format is set to Excel

    I am intending to attach the Macro to a button any ideas how I can do this?

    Best Regards

    Matt Fitzgerald
  • sierra7
    Recognized Expert Contributor
    • Sep 2007
    • 446

    #2
    Hi Matt
    I don't understand exactly what you mean by user profile. If you mean Windows Username then the attached utility will find it and put it into a string called "Username", that you can use.

    If you want something out of the Access workgroup file then someone else will have to help.

    To get the date just setup a string, set it to current date then concatonate with the Username string from the attached module. eg
    Code:
     Dim strDate as String 
    Dim strFileName as String
     
    strDate = Format(Date,"ddmmmyy") 'or whatever is your prefered format
     
    strFileName = Username & "_" & strDate
     
    'Output file = C:\Documents and Settings\Fitzgem4\Desktop\strFileName
    I would not use a macro, just write the code into the On_Click event procedure of the button.

    Hope this helps

    S7
    Attached Files
    Last edited by sierra7; Feb 1 '08, 02:24 PM. Reason: Adding utility

    Comment

    • MattFitzgerald
      New Member
      • Jul 2007
      • 30

      #3
      Thank you I did mean username and I now have it working

      Comment

      Working...