I'm having trouble here with Access 2007 and connecting to a different
database.
The code below works great IF the previous back-end database connection is
still present and you are trying to connect to a new location (ie: datapath
variable below).
However, if you remove or even rename the old database, then launch your
program, the code fails on the mytable.refreshlink line with an error 3044.
(Description of that error is: 'C:\pc
experts\develop\IQOFF2007\Database.accdb' is not a valid path. Make sure
that the path name is spelled correctly and that you are connected to the
server on which the file resides.) This doesn't happen for all linked
tables, just a handful (possible corruption in MSysObjects table). Here's
the code I'm using:
If MyTable.Connect <";DATABASE=" & datapath Then
MyTable.Connect = ";DATABASE=" & datapath
MyTable.RefreshLink
End If
So this is not good. Basically I was trying to test an end-user running the
program (and they naturally wouldn't have my development folder and
database), so I renamed the dev. folder, and the .refreshlink fails on a
handful of tables. Apparently you don't even have to rename the folder, you
can simply rename the db that you were originally connected to.
Now here's the interesting bit. I can't even manually re-link the tables
that wouldn't re-attach through the linked table manager (if the original
database is no longer present). Looking in the MSysObjects table, I did a
search under the Database column for the db that is no longer present. It
appears that there are some corrupt lines that include a reference to the
old db in the Database column, however the Foreign Name column is something
like: MSysComplexTypeVH_ and then a bunch of numbers.
Another odd thing, it doesn't do this for all linked tables, just some of
them, but even one table not re-linking is enough to throw off my
re-attachment routine.
I did try creating a blank database, and re-importing all objects. This
removed the corrupt MSysObjects lines, but on first launch, the corruption
happens again during the reattach process, and some tables simply won't
re-attach.
Can anyone confirm this on Access 2007? If you have an app with re-linking
code at the start, all you have to do is rename the db that your connected
to, then launch your app and see if you have the same problem.
Thanks!
Andy