Results 1 to 2 of 2
  1. #1
    Mclaren is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Feb 2010
    Location
    Johannesburg
    Posts
    164

    back end path

    I have the following code which works and gives me the path to my back end, iy includes the name of the MDB file. I need the string returned to omit the MDB file. ie:



    C:\Users\Kevin\Desktop\CSSimplyDB\Data\backend.mdb
    should read:
    C:\Users\Kevin\Desktop\CSSimplyDB\Data
    Code:
    Public Function GetDBPath() As String
        Dim strFullPath As String
        strFullPath = Mid(DBEngine.Workspaces(0).Databases(0).TableDefs("tbl_Contacts").Connect, 11)
    
        For I = Len(strFullPath) To 1 Step -1
            If Mid(strFullPath, I, 1) = "\" Then
                GetDBPath = Left(strFullPath, I)
                Exit For
            End If
        Next
    End Function
    Can anyone please explain to me what the above code does, so i can understand how it works.

  2. #2
    jgelpi16 is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    I recommend dumping this code into a module and stepping through it. This will help you understand what the code is doing. Just use "F8" to step through the code. What you can do is simply use the replace function on strFullPath....

    Code:
    Replace(strFullPath, ".mdb", "")
    I have not stepped through this code, but what it looks like it is doing is removing all the "\" from the string in strFullPath. If your desired outcome is simply to have the path less the ".mdb" extension I would suggest the following...

    Code:
    Public Function GetDBPath() As String
        Dim strFullPath As String
        strFullPath = Mid(DBEngine.Workspaces(0).Databases(0).TableDefs("tbl_Contacts").Connect, 11)
     
    GetDBPath = Replace(strFullPath, ".mdb", "")
    End Function

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

Similar Threads

  1. not a valid path
    By JJJ in forum Access
    Replies: 0
    Last Post: 03-28-2011, 10:50 AM
  2. Find UNC path
    By jordanturner in forum Access
    Replies: 2
    Last Post: 09-17-2010, 09:18 AM
  3. Not a valid path
    By hhuuhn in forum Access
    Replies: 2
    Last Post: 08-23-2010, 02:06 PM
  4. parametrize file path
    By ysrini in forum Access
    Replies: 3
    Last Post: 03-01-2010, 09:37 AM
  5. Programming the BackEnd path
    By James3mc in forum Programming
    Replies: 6
    Last Post: 11-21-2009, 06:39 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