Results 1 to 5 of 5
  1. #1
    bdaniel is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    44

    CurDir() doesn't give current directory

    DIM'ng variable spath as string, then assigning value spath=CurDir().

    When I move the program to another user's computer, CurDir() equals the users directory path, not the location of the database. For example I can put the database anywhere on my computer and it references the correct directory, I put it on my wife's computer and CurDir returns c:\users\patrice\documents even though the database is located in c:\users\patrice\documents\production module test\production module test(2).

    When I placed the program on my work server, CurDir() returns c:\.



    Any ideas?

    Was using this so the program would reference files located in the folder the database is located. Guess if doesn't work, will just have to hard code the location into the program by declaring a string value to the directory path.

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    CurrDir is not what you want. You want

    CurrentProject.Path

    is what you want. But to return that you will need to create a function:

    Code:
    Function GetCurDir() As String
        GetCurDir = CurrentProject.Path
    End Function
    and then you can call it

    =GetCurDir()

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,957
    Try:
    CurrentProject.Path & "\"

    Check out http://www.ammara.com/access_image_f...base_path.html
    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.

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    I just tested and this works in 2010 (not sure about 2007):

    =[Currentproject].[path]

    So you may not need the wrapper function.

  5. #5
    bdaniel is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    44

    Talking

    Thanks. That works.

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

Similar Threads

  1. Should I give Up on This Form?
    By Palomino33 in forum Forms
    Replies: 25
    Last Post: 11-09-2011, 05:37 AM
  2. Unexpected Results from Curdir?
    By bginhb in forum Programming
    Replies: 6
    Last Post: 08-17-2011, 03:58 PM
  3. Replies: 6
    Last Post: 06-15-2011, 04:38 PM
  4. Replies: 7
    Last Post: 01-19-2011, 10:39 AM
  5. Replies: 3
    Last Post: 12-08-2009, 01:02 AM

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