Option Compare Database
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
' ------------------------------------------------------------------
' linking code adapted from namliam's code on AWF
' http://www.access-programmers.co.uk/forums/showthread.php?t=180962
' ------------------------------------------------------------------
Dim tbl As TableDef
Dim x As Long, MaxX As Long
Dim tblDB As String
Me.Visible = False
[COLOR=Red]
tblDB = myFolder & "\ORDERS_ReferenceLabs_be.mdb"
If Dir(tblDB) = "" Then ' local BE not found, use server BE.
tblDB = "\\wm-icpmr\Data2\SHARED\Cidmls\Molecular Biology\Orders\ORDERS_ReferenceLabs_be.mdb"
End If
[/COLOR]
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 = myFolder & Mid(tbl.Connect, InStr(1, tbl.Connect, "\"))
If tbl.Connect <> ";Database=" & tblDB Then
Me.Visible = True
Me.Repaint
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... Opening login form."
Me.Repaint
MaxX = Timer + 2
Do While Timer <= MaxX
Loop
End If
DoCmd.OpenForm "frmLogin"
DoCmd.Close acForm, Me.Name
Exit_Form_Open:
Exit Sub
Err_Form_Open:
Msg = "Error # " & Str(Err.Number) & Chr(13) & " (" & Err.Description & ")"
Msg = Msg & Chr(13) & "in Form_frmWAIT | Form_Open"
MsgBox Msg, vbMsgBoxHelpButton, "RLS Order Records", Err.HelpFile, Err.HelpContext
Resume Exit_Form_Open
End Sub
Function myFolder()
On Error GoTo Err_myFolder
myFolder = Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\"))
Exit_myFolder:
Exit Function
Err_myFolder:
Msg = "Error # " & Str(Err.Number) & Chr(13) & " (" & Err.Description & ")"
Msg = Msg & Chr(13) & "in Form_frmWAIT | myFolder"
MsgBox Msg, vbMsgBoxHelpButton, "RLS Order Records", Err.HelpFile, Err.HelpContext
Resume Exit_myFolder
End Function