H
Hugo Kornelis
Hi all,
I have an Access application that serves as a fron end for a SQL Server
database. Since our customers use different names for their SQL Server
servers (and possibly choose a different name for the database as well),
I had to come up with a way to allow the customers to change the
connection strings for all linked table with minimal effort.
After asking around, I was pointed to the FixConnection routine as
written by MVP Doug Steele
(http://www.accessmvp.com/djsteele/DSNLessLinks.html). I made a simple
form where the users can enter a server- and databasename and that then
calls FixConnections to change all connection strings to point that
server and database. Worked like a charm, and life was good.
But just now, I got an email from a customer: the front-end refused to
open some of the forms because the linked tables were gone. After some
digging, I found the result - apparently, there had been some attempts
to change connection strings towards a misspelled server or database
name. The on error routine in Doug's code will catch this and abort the
process - but only after deleting the first linked table! So each time a
user errs while specifying server or database, one of the linked tables
disappears. (The copy I got from this particular customer had less than
half of its linked tables left, which is probably saying something about
how they work <g>)
Since I can't prevent with 100% reliability that users err while typing
a server or table name, I need some other way to prevent the access
application losing its linked tables. One option would be to somehow
"undo" the removal of the original table if the creation of the new
version with the updated conenction fails. Another option would be to
test the validity of the server and database specified before calling
the FixConnections script. But unfortunately, either of these options
seems to be beyond my VBA coding capabilities.
So, has anyone here encoutered a similar problem? How did you solve it?
Any ideas and suggestions are most welcome!
(BTW - I'm using Access 2003, in case it matters)
I have an Access application that serves as a fron end for a SQL Server
database. Since our customers use different names for their SQL Server
servers (and possibly choose a different name for the database as well),
I had to come up with a way to allow the customers to change the
connection strings for all linked table with minimal effort.
After asking around, I was pointed to the FixConnection routine as
written by MVP Doug Steele
(http://www.accessmvp.com/djsteele/DSNLessLinks.html). I made a simple
form where the users can enter a server- and databasename and that then
calls FixConnections to change all connection strings to point that
server and database. Worked like a charm, and life was good.
But just now, I got an email from a customer: the front-end refused to
open some of the forms because the linked tables were gone. After some
digging, I found the result - apparently, there had been some attempts
to change connection strings towards a misspelled server or database
name. The on error routine in Doug's code will catch this and abort the
process - but only after deleting the first linked table! So each time a
user errs while specifying server or database, one of the linked tables
disappears. (The copy I got from this particular customer had less than
half of its linked tables left, which is probably saying something about
how they work <g>)
Since I can't prevent with 100% reliability that users err while typing
a server or table name, I need some other way to prevent the access
application losing its linked tables. One option would be to somehow
"undo" the removal of the original table if the creation of the new
version with the updated conenction fails. Another option would be to
test the validity of the server and database specified before calling
the FixConnections script. But unfortunately, either of these options
seems to be beyond my VBA coding capabilities.
So, has anyone here encoutered a similar problem? How did you solve it?
Any ideas and suggestions are most welcome!
(BTW - I'm using Access 2003, in case it matters)