Compare Page Revisions
« Older Revision - Back to Page History - Current Revision
Private Sub Form_Load() Dim rst As DAO.Recordset Dim intNumTables As Integer Dim varReturn As Variant Dim intI As Integer Dim tdf As TableDef Dim fd As Office.FileDialog Dim vrtSelectedItem As Variant Dim sFileName As String On Error Resume Next Set rst = CurrentDb.OpenRecordset("AcctExec", dbOpenDynaset) 'check for failure - the link must be bad. If Err <> 0 Then 'get the new location Set fd = Application.FileDialog(msoFileDialogFilePicker) fd.Title = "Please select the backend database" fd.Filters.Clear fd.Filters.Add "Access Databases", "*.accdb" If fd.Show = True Then For Each vrtSelectedItem In fd.SelectedItems sFileName = vrtSelectedItem Next End If 'Rebuild the links. Check for the number of tables first intNumTables = CurrentDb.TableDefs.Count varReturn = SysCmd(acSysCmdInitMeter, "Relinking tables", intNumTables) 'Loop through all tables. Reattach those with nonzero-length Connect strings intI = 0 For Each tdf In CurrentDb.TableDefs 'if connect is blank, it's not a linked table If Len(tdf.Connect) > 0 Then intI = intI + 1 tdf.Connect = ";DATABASE=" & sFileName tdf.RefreshLink End If varReturn = SysCmd(acSysCmdUpdateMeter, intI) Next tdf varReturn = SysCmd(acSysCmdRemoveMeter) End If End Sub
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.