Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


determine users profile path for export path in MS Access

Posted on 2009-12-31
Medium Priority
Last Modified: 2013-12-05
I'm exporting reports and queries within MS Access ADP application.  I've been using the users 'C' drive as the location of there "My Documtents" folder, but this isn't the case when the user works remotely.
How do I determine the path of their "My Documents" folder so I can export the file there?

Below is some of the code showing where I hard coded the path and an attempt at using
%Userprofile% as a wild card which didn't work.  myGetUserName is a function I use to get
the login name of the user.

Help is appreciated.

On Error GoTo viewReport_Error
    Dim myReport As String
    Dim temp As String
    temp = %Userprofile% & myGetUserName & "\My Documents\"
    myReport = Me!lbReportName.Column(2)
    myFilePath = "C:\Documents and Settings\" & myGetUserName & "\My Documents\"
Question by:jvantassel1
  • 2
LVL 39

Expert Comment

ID: 26154526
The format you tried %Userprofile% is for batch files. For VB, Try:
 temp = Environ("Userprofile") & myGetUserName & "\My Documents\"
LVL 39

Expert Comment

ID: 26154537
For user name use;

Accepted Solution

ppango earned 2000 total points
ID: 26154757
thenelson is right. however, i believe that
temp = Environ("Userprofile") & "\My Documents\"
should be enough as userprofile will return also the login name.


Author Closing Comment

ID: 31671609
This worked perfectly.  I've been coding in Access for years and didn't know this.  Thanks.

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Implementing simple internal controls in the Microsoft Access application.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question