Oh, and the link this came from, which also seems to have the error:
https://www.microsoft.com/en-us/micr...access-tables/
Oh, and the link this came from, which also seems to have the error:
https://www.microsoft.com/en-us/micr...access-tables/
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.
I tried it and it works. The lag time to do this process seems to be about 2 seconds.Code:strBackEnd = Right$(strCon, (Len(strCon) - (InStrRev(strCon, "\") - 1)))
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
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.
benefit of using code tagsGeez, 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.[/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
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:
Apparently ExitHere: can't be used more than once.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
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