when I run the code below as part of a larger system, as an accdb file the split database is correctly connected to the appropriate data source, external hard drive or university server.
I can nominate either source and the connection is completed correctly.
If I run the exact same code as an accde file, converted immediately after running the accdb, the code appears to run correctly but the data source is not changed.
The fact that the accde file is created is proof in itself of no coding errors.
I have tried this multiple times with the accdb and converted to accde immediately after a successful test and get the same result every time.
If I do the source change in the accdb file then run the accde without a source change, all functions operate normally.
I hope you can understand the problem from this description, I certainly don't understand the problem as it occurs.
I can nominate either source and the connection is completed correctly.
If I run the exact same code as an accde file, converted immediately after running the accdb, the code appears to run correctly but the data source is not changed.
The fact that the accde file is created is proof in itself of no coding errors.
I have tried this multiple times with the accdb and converted to accde immediately after a successful test and get the same result every time.
If I do the source change in the accdb file then run the accde without a source change, all functions operate normally.
I hope you can understand the problem from this description, I certainly don't understand the problem as it occurs.
Code:
Public Sub re_Link()
Dim T As TableDef
Dim td As TableDefs
Dim sSource As String
Dim nNum2 As Integer
Dim nNum1 As Integer
nRed = 255
nGrn = 0
nCng = 0
Me.btnGauge.Visible = True
On Error Resume Next
Set td = oDB.TableDefs
nNum1 = td.Count
nNum2 = 1
sSource = TempVars!src & "_be.accdb"
For Each T In td
If T.Connect <> ";DATABASE=" & sSource Then
T.Connect = ";DATABASE=" & sSource
T.RefreshLink
doBar nNum1, nNum2
nNum2 = nNum2 + 1
End If
Next
Set T = Nothing
Set td = Nothing
End Sub
Private Sub doBar(nNum1 As Integer, nNum2 As Integer)
Dim nWidth As Long
nWidth = Int(((nNum2 / nNum1) * 100))
If nCng < nWidth Then
nGrn = IIf(nGrn >= 255, 255, IIf(nRed = 255, nGrn + 5, nGrn))
nRed = IIf(nRed <= 0, 0, IIf(nGrn = 255, nRed - 5, nRed))
nCng = nWidth
Me.btnGauge.BackColor = RGB(nRed, nGrn, 0)
End If
If nWidth > 12 Then
Me.btnGauge.Left = Me.btnGauge.Left - 6
Me.btnGauge.Width = nWidth * 40
End If
Me.btnGauge.Caption = nWidth & "%"
DoEvents
End Sub