I have a great routine that allows me to select diffent backend databases to link to. I also use it to check for the backend database at the time of start up and if it's missing the routine links to a default backend database.
The problem is...if the computer crashes or the user manually end tasks the program for some reason in the middle of the relink, the next time the person logs in they will be short a table or two so any subsequent relinks will always be short a table because it's no longer part of AllTables.
This is the jist of the routine/function.
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentData
For Each obj In dbs.AllTables
strTableName = obj.name
If Not (Left(strTableName, 4) = "MSys" Or strTableName = "stblSN" Or strTableName = "tblDefaults" Or strTableName = "tblSoftware") Then
DoCmd.DeleteObject acTable, strTableName
DoCmd.TransferDatabase acLink, "Microsoft Access", strFilename, _
acTable, strTableName, strTableName
End If
Next obj
My thoughts were to have the routine delete all the links then go out to the selected backend database and relink to all of the tables in that selected backend rather than doing the transferdatabase. I can't figure out how to do this though.
The problem is...if the computer crashes or the user manually end tasks the program for some reason in the middle of the relink, the next time the person logs in they will be short a table or two so any subsequent relinks will always be short a table because it's no longer part of AllTables.
This is the jist of the routine/function.
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentData
For Each obj In dbs.AllTables
strTableName = obj.name
If Not (Left(strTableName, 4) = "MSys" Or strTableName = "stblSN" Or strTableName = "tblDefaults" Or strTableName = "tblSoftware") Then
DoCmd.DeleteObject acTable, strTableName
DoCmd.TransferDatabase acLink, "Microsoft Access", strFilename, _
acTable, strTableName, strTableName
End If
Next obj
My thoughts were to have the routine delete all the links then go out to the selected backend database and relink to all of the tables in that selected backend rather than doing the transferdatabase. I can't figure out how to do this though.