Page 3 of 3 FirstFirst 123
Results 31 to 38 of 38
  1. #31
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Oh, and the link this came from, which also seems to have the error:

    https://www.microsoft.com/en-us/micr...access-tables/


    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  2. #32
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    You meant the correction to include the backslash within the quotes. I just discovered why your backslash was missing. It is removed when the post is saved. Need to surround the code with the code block to preserve the blackslash.
    Code:
    strBackEnd = Right$(strCon, (Len(strCon) - (InStrRev(strCon, "\") - 1)))
    
    I tried it and it works. The lag time to do this process seems to be about 2 seconds.

    This would be a good piece of code to include on your PBaldy website. It would be good to also have it only run when the back-end file cannot be found in the current path. Given that the full path is in strCon, using strCon, how do I query within the function to see if the path is valid?

    For those who might be interested in what this latest discussion is about. It is concerning a solution offered by MS to auto-relink back-end tables when the db location has changed. It is found here:
    https://www.microsoft.com/en-us/micr...access-tables/
    But it has a bug, which fix is mentioned in this post.

    Thanks

  3. #33
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Geez, I didn't notice that the backslash got stripped from my post.

    I would think you could compare CurrentProject.Path to the part of strCon before the final backslash.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #34
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    Geez, I didn't notice that the backslash got stripped from my post.
    benefit of using code tags

  5. #35
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by Ajax View Post
    benefit of using code tags
    I'm new here, still learning...

    The frustrating thing is I usually proof read after posting. Clearly didn't do a good job of that.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #36
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    I would think you could compare CurrentProject.Path to the part of strCon before the final backslash.[/QUOTE]

    I tried doing this comparison as you suggested, but the compiler complains. I placed the following If clause just before loop.
    Code:
    'If the link path is the same as the current project path quit.
    If CurrentProject.Path = Left$(strCon, (Len(strCon) - (InStrRev(strCon, "\")))) Then
    ExitHere:
    End If
    
    'Loop through the TableDefs Collection.
    For Each tdf In db.TableDefs

  7. #37
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    I would think you could compare CurrentProject.Path to the part of strCon before the final backslash.[/QUOTE]

    I did some more research and found the StrComp() function and changed this code to:
    Code:
    'If the link path is the same as the current path quit
    If StrComp(CurrentProject.Path, Left$(strCon, (Len(strCon) - (InStrRev(strCon, "\"))))) Then
    'Do nothing
    Else
    'Loop through the TableDefs Collection.
    For Each tdf In db.TableDefs
    Apparently ExitHere: can't be used more than once.

  8. #38
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Well, the way you're using it, it's like a variable. It would be used in conjunction with GoTo, like somewhere you'd have

    GoTo ExitHere

    As such, correct, it can only be defined once, just as you can't declare strCon twice. In that spot, I'd either:


    • Let the If/Then block handle it, as you appear to have done. In other words, if it doesn't perform the code in the If section there's nothing after the End If to skip over anyway.
    • Use Exit Sub to simply exit the procedure immediately
    • If I had error handling, which I normally do, I'd have GoTo Exithandler there
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 09-16-2018, 04:58 PM
  2. Replies: 8
    Last Post: 11-16-2017, 03:07 PM
  3. Replies: 4
    Last Post: 03-19-2015, 08:43 AM
  4. Formatting military time into non-military time
    By WithoutPause in forum Access
    Replies: 3
    Last Post: 11-18-2013, 07:40 AM
  5. Replies: 42
    Last Post: 03-01-2013, 06:58 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