title: Seemingly getting wrong connection string from tabledef
body: <p>Using Ms Access ...</p>
  
  <p>I am trying to change the user to which I am connected to a SQL Server Database from Access. The startup form from my Access Application dynamically connects to the tables via an Altered version of a routine posted on Microsoft's KB.  In Essence it deletes the tabledef that matches the name localName you call it with, Calls Currentdb.CreateTableDef to create a new one with the appropriate new connection string and appends it the the CurrentDb.TableDefs collection.  As far as I can see, its the append function that actually contacts the database and throws an error if your connection string is wrong.</p>
  
  <p>In my case, I did an original pass through all the tables in my database calling this routine with an old (standardised - ie I normally use this) string and all tables connect fine.</p>
  
  <p>I am now trying a second pass through this start up form with a new user/password combination so as to test different permissions in the database.</p>
  
  <p>I have then built a new connection string with a revised name and password and am currently single stepping through the function I just described.</p>
  
  <p>I have a variable td which contains the newly created tabledef and I am just prior to appending it to the Currentdb.TableDefs collection</p>
  
  <p>In the debugger "Immediate" window <code>?td.connect</code> gives the connection string with the newly formed connection string correctly and <code>?td.name</code> gives <code>tblConfig</code> as the table name.</p>
  
  <p>Just to ensure the TableDef has been correctly deleted from the current collection I did <code>?CurrentDb.Tabledefs("tblConfig").Connect</code> from the immediate window and was rewarded with a dialog box that said the collection didn't contain a member with that name</p>
  
  <p>I then single step over the line</p>
  
  <pre><code>CurrentDb.TableDefs.Append td
  </code></pre>
  
  <p>And now call <code>?CurrentDb.Tabledefs("tblConfig").Connect</code> again from the debuggers Immediate window and the response is the old connection string not the new one.</p>
  
  <p>There is an OnError active in this routine, but It is not activated during the single stepping.</p>
  
  <p>The only explanation I can think of for this, is that somehow the old connection string is stored on disk as a result of saving the database at some point and append doesn't copy across the connectionstring when it is finally appended.</p>
  
  <p>Does anyone have a better explanation?</p>