Results 1 to 7 of 7
  1. #1
    mortonsafari is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2015
    Location
    Brisbane, Queensland, Australia
    Posts
    39

    Code help for generic file location for each user

    I have Code as follows which creates a pdf file from a report and then places it in my C: drive in C:\Users\user\Documents.

    [ DoCmd.OutputTo acOutputReport, "rCAT-Filter", "PDFFormat(*.pdf)", "C:\Users\user\Documents\ProfContCAT.pdf", True, "", 0, acExportQualityPrint ]

    What I want to do is place a copy of the database on the network, and then when the ‘user’ on their machine accesses the database and creates the report, the report will save to their C: drive and User profile in their Documents folder.



    What do I need to do to achieve this?

    All help appreciated. Kind regards, mortonsafari

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Maybe:

    "C:\Users\" & Environ("USERNAME") & "\Documents\ProfContCAT.pdf"
    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
    mortonsafari is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2015
    Location
    Brisbane, Queensland, Australia
    Posts
    39
    Thanks June7, appreciate the tip. That didn't do the trick as it threw an error saying the action was cancelled. However, I have directed the file to a common network drive and folder which solves the problem somewhat.
    Regards..... mortonsafari

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    What I want to do is place a copy of the database on the network, and then when the ‘user’ on their machine accesses the database
    Just checking. You have split the database? And there is a copy of the front end on each machine?

  5. #5
    mortonsafari is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2015
    Location
    Brisbane, Queensland, Australia
    Posts
    39
    moke123 . . . thanks for your response. No, I have not split it. I work on a Master copy and have a copy on our main server which can be accessed by anyone with access to the server.
    My original intention was that when the 'user' generated a pdf file from the relevant report, it would be saved to their desk PC in their documents folder. Because of the nature of the organisation that I volunteer in, some users do not have a great understanding of DB's/computers and I was trying to simplify things.
    I have now created a Folder on the server, and point all the 'pdf' files to that location, where they can be accessed fairly easily.
    This seems to be OK.
    Thanks for your interest. However, if you have an easy fix . . . let me know.
    Kind regards
    Mortonsafari

  6. #6
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643
    Your database should be split with backend on the server and front end on each users computer.
    Could be that the path your using doesnt exist on the server and thus errors.

    heres a longer piece of code to show the path to local Documents folder. Note that the documents folder is considered a special folder as are the others listed as constants below. It's a sub but can be easily converted to a function.
    Paste to a standalone module and run ShowFolder

    Code:
    ' Get path of Special folders
    Type ShortItemId
         cb As Long
         abID As Byte
    End Type
    
    
    Type ITEMIDLIST
         mkid As ShortItemId
    End Type
    
    
    Const CSIDL_PROGRAMS = 2                  ' Program Groups Folder
    Const CSIDL_PERSONAL = 5                  ' Personal Documents Folder
     Const CSIDL_FAVORITES = 6                 ' Favorites Folder
     Const CSIDL_STARTUP = 7                   ' Startup Group Folder
     Const CSIDL_RECENT = 8                    ' Recently Used Documents Folder
     Const CSIDL_SENDTO = 9                    ' Send To Folder
     Const CSIDL_STARTMENU = 11                ' Start Menu Folder
     Const CSIDL_DESKTOPDIRECTORY = 16         ' Desktop Folder
     Const CSIDL_NETHOOD = 19                  ' Network Neighborhood Folder
     Const CSIDL_TEMPLATES = 21                ' Document Templates Folder
     Const CSIDL_COMMON_STARTMENU = 22         ' Common Start Menu Folder
     Const CSIDL_COMMON_PROGRAMS = 23          ' Common Program Groups Folder
     Const CSIDL_COMMON_STARTUP = 24           ' Common Startup Group Folder
     Const CSIDL_COMMON_DESKTOPDIRECTORY = 25  ' Common Desktop Folder
     Const CSIDL_APPDATA = 26                  ' Application Data Folder
     Const CSIDL_PRINTHOOD = 27                ' Printers Folder
     Const CSIDL_COMMON_FAVORITES = 31         ' Common Favorites Folder
     Const CSIDL_INTERNET_CACHE = 32           ' Temp. Internet Files Folder
     Const CSIDL_COOKIES = 33                  ' Cookies Folder
     Const CSIDL_HISTORY = 34                  ' History Folder
    
    
     Declare Function SHGetPathFromIDList Lib "shell32.dll" _
        (ByVal pidl As Long, _
        ByVal pszPath As String) As Long
    
    
     Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" _
        (ByVal hwndOwner As Long, _
        ByVal nFolder As Long, _
        pidl As ITEMIDLIST) As Long
    
    
    
    
    Sub ShowFolder()
        Dim lngID As Long
        Dim IDL As ITEMIDLIST
    
    
        Dim strPath As String
        Dim strShortCut As String
    
    
        ' Fill the idl structure with the specified folder item.
        lngID = SHGetSpecialFolderLocation(0, 5, IDL) '<<<<<Change second arguement here. 5 = CSIDL_PERSONAL
    
    
        ' Get the path from the idl list, and return
        ' the folder with a slash at the end.
        If lngID = 0 Then
            strPath = Space$(260)
            lngID = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal strPath)
    
    
            If lngID Then
                strPath = Left$(strPath, InStr(strPath, Chr$(0)) - 1) & "\"
            End If
    
    
            If strPath <> "" Then
                MsgBox "My documents = " & strPath
            Else
                MsgBox "Unable to find"
            End If
        End If
    
    
    End Sub

  7. #7
    mortonsafari is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jul 2015
    Location
    Brisbane, Queensland, Australia
    Posts
    39
    moke123 . . . many thanks for your response. I will look into it and see how it goes.
    Cheers . . . mortonsafari

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

Similar Threads

  1. Replies: 4
    Last Post: 08-15-2017, 08:44 AM
  2. Replies: 1
    Last Post: 03-31-2016, 08:31 AM
  3. User pick location to save expoerted data
    By MrDummy in forum Import/Export Data
    Replies: 6
    Last Post: 03-29-2016, 03:04 PM
  4. Replies: 3
    Last Post: 10-16-2014, 08:49 AM
  5. File Location
    By Mitch87 in forum Programming
    Replies: 1
    Last Post: 02-19-2010, 11:12 AM

Tags for this Thread

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