' Creator: namliaM
' Created: 2005-11-05
' Forum: www.access-programmers.co.uk/forums
' This runs in a form, with a progress meter on it
' and relinks this front end to the backend which is located
' in a subfolder called Tables, this form by default opens invisible.
Dim tbl As dao.TableDef
Dim x As Long, MaxX As Long
Dim tblDB As String
Me.Visible = False
tblDB = myCurrDir & "Tables\*.mdb"
If Dir(tblDB) = "" Then
MsgBox "No table database has been found, " & vbCr & vbCr & _
"This application will not work, so its beeing closed", vbCritical
Application.Quit
End If
resetShadows
MaxX = 1 ' first count all attached tables
For Each tbl In CurrentDb.TableDefs()
If tbl.Attributes = dbAttachedTable Then MaxX = MaxX + 1
Next tbl
x = 1 ' Now update them
For Each tbl In CurrentDb.TableDefs()
If tbl.Attributes = dbAttachedTable Then
tblDB = myCurrDir & Mid(tbl.Connect, InStr(1, tbl.Connect, "Tables"))
If tbl.Connect <> ";Database=" & tblDB Then
Me.Visible = True
Me.Repaint
DoEvents
tbl.Connect = ";Database=" & tblDB
tbl.RefreshLink
End If
x = x + 1
End If
Me.Fill.Width = x / MaxX * Me.FillTo.Width
Next tbl
If Me.Visible Then
Me.lblWait.Caption = "Done relinking ... "
Me.Repaint
MaxX = Timer + 2
Do While Timer <= MaxX
Loop
End If
DoCmd.OpenForm "frmMain"
DoCmd.Close acForm, Me.Name