How can I use vba to delete connection to external tables.accdb and reconnect to them?
Posted on 2012-03-14
My ultimate goal here is during logon, the user also has a dropdown box where they can select whether to connect to the test tables or the live tables. So I will just write an if statement in vba that will look at which is selected in the drop down box when they click logon and will create the link to the tables in the corresponding external .accdb file containing the tables.
So here is some mocked up code of what I think it may look like;
Private Sub cmdLogon_Click()
if me.cboEnvironment = "Test" then
CreateConnection = "\\sfile0\Data\Inspection\FAIDatabase\Tables\TestTables.accdb", Connect to all Tables"
CreateConnection = "\\sfile0\Data\Inspection\FAIDatabase\Tables\Tables.accdb", Connect to all Tables
**Oh and I guess I would need to delete the connection to the current tables first?
That's just my theoretical idea of what the code would look like.. I really don't have a clue what the connection vba looks like.
Thanks for your advice and assistance!