Display path to backend Folder in Txtbox on form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neelsfer
    Contributor
    • Oct 2010
    • 547

    Display path to backend Folder in Txtbox on form

    I would like to display the path folder to my BE files on the Startup form in a textbox, to ensure it is linked through the correct path to the correct folder.
    I have tried the following code in the Open event on the Startup form, but unsuccessfully.
    Code:
    Dim strBEPath As String
    strBEPath = DLookup("[Database]", "MSysObjects", "[ForeignName]='PisDataV3.0.accdb'")
    the path is usually c:\pisprg but maybe on the network also
    Any suggestions?
  • dsatino
    Contributor
    • May 2010
    • 393

    #2
    First, I don't see where you're actually assigning the string variable to a text box anywhere.

    If you've simply left that out because of it's obviousness, then there are a couple of easy trouble shooting actions I would take.
    1. Stick the dlookup() function in the immediate pane and see if it actually returning something. If it isn't, then you know you've mis-spelled the foreign name. if it is, then:
    2. debug.print the variable immediately before it's applied to the text box to ensure that variable isn't null. If it's null, then you're not capturing it or possibly erasing it. If it returns the value then:
    3. Check the syntax of how you're applying it to the text box.
    i.e. form.textbox="= 'stringvalue'"

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      There are several Methods to extract the Back End PATH and this is just one of them (keeping in line with initial approach).
      Code:
      Dim tdf As DAO.TableDef
      
      For Each tdf In CurrentDb.TableDefs
        If tdf.Connect <> "" Then
          Debug.Print tdf.NAME, DLookup("[Database]", "MSysObjects", _
                      "[ForeignName] = '" & tdf.NAME & "'")
        End If
      Next

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        If you are using linked tables, what I would do is:
        Take One of the linked tables of known name
        Using the DAO object model, tabledefs collection check that the table is still a linked type (dbAttachedTabl e) if so, then return Left(len(path)-len(tablename)) .
        Infact that is what I do, I then check that the file exists first before attempting anything else in my split databases.
        Last edited by zmbd; Jan 31 '14, 10:43 PM. Reason: [z{just clicked post and there was ADezii's post (^_^) }]

        Comment

        Working...