Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Leuven, Vlaanderen, Belgium
    Posts
    322
    Thanks
    9
    Thanked 0 Times in 0 Posts

    TableDef.Connect retuns no full path (97)

    Valuable members of this board,
    does tabledef's Connect property always return a 8-char-abbreviated path (but the file name in full)? How do you get a full path? For example...
    For this backend path:
    ...so_ClusterDatabankenWater_SubsLongBackendName.m db
    the connect property yields:
    ...SO~B1WY7WA~B21S5LongBackendName.mdb
    I tried a couple of different approaches, got for a short while some wacko results which fortunately disappeared but still, with my Access 97 'stabilised' again, I can't get it right. Some searches didn't provide any solution & I can't motivate myself to further examine that flood of threads, FAQ's & articles about using VBA to retrieve a linked table's source file, as this is so specific...

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: TableDef.Connect retuns no full path (97)

    I don't remember how it was in Access 97, and whether it depends on the Operating System. In Access 2002 on Windows XP, the Connect property stores the long path and file name.

    You can use the GetFullPathName API function to retrieve the long path name belonging to a short one.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: TableDef.Connect retuns no full path (97)

    If Access 97 stores a "short path" in the Connect property, no API function is going to change that - even if you feed it a "full path", Access will convert it to a "short path". I meant that if you ever needed to reconstruct the "full path" from the abbreviated version, you could use an API function.

  4. #4
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Leuven, Vlaanderen, Belgium
    Posts
    322
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Re: TableDef.Connect retuns no full path (97)

    <P ID="edit" class=small>(Edited by hasse on 24-Nov-04 20:45. Applied code formatting to Code line)</P>Hans,
    I guess it's the Office version (97) and not the Operating System (NT), and that 'back then' the Connect property stored no full path yet: on the same site you refer to, I bumped in PromptFileName(), another API-function which yields the actual file's full path using from the Open File Dialog (no add-ins or whatever needed - might be a good start for a workaround, if ever...). I assigned the resulting 'fresh' full path to the Connect property, retrieved the property's value immediately afterwards and... found the full path 'lost' again:
    <pre>Public Sub test()
    MsgBox "Original MyTable.Connect = " & GetLinkedDBName("MyTable") '=> abbreviated path
    CurrentDb.TableDefs("MyTable").Connect = PromptFileName()
    '=> Function includes added Msgbox yielding full path
    MsgBox "New MyTable.Connect = " & GetLinkedDBName("MyTable") 'abbreviated path (again)
    End Sub</pre>

    (Or am I misinterpreting this?)

    Also using your suggestion, I get the same result: no full path. I might have made a mistake though, as I'm no 'educated' programmer (not speaking of API). So... did I do it correctly like this...?
    I created a new function (GetFullLinkedDBName) in which I 'feed' the path string yielded by the original function (GetLinkedDBName) as a variable to the API-function (GetFullPathName):
    <pre>GetFullLinkedDBName = GetFullPathName(GetLinkedDBName(TableName), 255, Buffer, "")</pre>

    Attachment: complete code used, with 'test' function for try-out (replacing "MyTable" with...)
    If my code is OK, the problem remains unsolved (but is was certainly a nice try, so still <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>). Then, I will ask no further, as I have to put this aside for higher priorities... This swallowed too much of my time already.
    But if not, please let me know the correct application of the function - then I'll give it a last try.

  5. #5
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Leuven, Vlaanderen, Belgium
    Posts
    322
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Re: TableDef.Connect retuns no full path (97)

    Sorry for not making myself clear...
    Hans, I think I got your point, even though I needed that other API-function to make me realise this.

    Actually, my question was: why does this API-function fail in my code? As I can't find what might have escaped me... (cf. previous post): the custom GetLinkedDBName function yields the "short path" from the Connect property value. This value is passed to the GetFullPathName API-function, which should reconstruct the "full path" from that "short path". But... it doesnt <img src=/S/broke.gif border=0 alt=broke width=31 height=23>.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: TableDef.Connect retuns no full path (97)

    I'm sorry, I hadn't actually tested it myself <img src=/S/stupidme.gif border=0 alt=stupidme width=30 height=30>

    You will find a working function fGetLongName (I tested it this time) in API: Get Short and Long file names on the Access Web.

  7. #7
    3 Star Lounger
    Join Date
    Aug 2002
    Location
    Leuven, Vlaanderen, Belgium
    Posts
    322
    Thanks
    9
    Thanked 0 Times in 0 Posts

    SOLVED Re: TableDef.Connect retuns no full path

    All's well that ends well :-)... these functions did the job!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •