When I set password in my Backend database, then re-link my front end
database. When I log in as developer from the FE, I got a message "Runtime
Error 3031, not a valid password:
I want to write a code so that when any user log in from the front end, via
MDW using their normal log in .
Below is the code that Debug takes me to.
the errors occur at the tdf.RefreshLink
"""""
Function Refresh_Links(lngSpeed As Long, strDatabaseName As String)
'On Error GoTo Handle_Refresh_Links_Error
Dim AdAcctName As String, AdPwd As String
Dim wrkJet As Workspace
Dim db As Database
Dim tdf As TableDef
Dim intI As Integer, intNumTables As Integer
Dim lngOneHundredPercent As Long, lngProgressRatio As Long, lngCounter As
Long, lngcounterstart As Long
Dim lngCounterEndRange As Long, strCurrentDbDir As String
'--------------------------------------------------------------------------------
'Mohan Thavakulasingam 03-07-2002
'--------------------------------------------------------------------------------
'Work out password word of backend for use later below
Application.SetOption "ShowWindowsInTaskbar", False
DoCmd.OpenForm "frmOFS_LinkStatus" ', , , , , , "Re-establishing
Links"
'fSetAccessWindow (SW_HIDE)
'--------------------------------------------------------------------------------
'Mohan Thavakulasingam 03-07-2002
'--------------------------------------------------------------------------------
'Get the width of the progress bar for frmOFS_LinkStatus form
lngOneHundredPercent =
Forms![frmOFS_LinkStatus]![LineShadow].Width 'Overshoot compensation
'Set the moving bar to a widt of zero
Forms![frmOFS_LinkStatus]![LineProgress].Width = 0
'Give a half a second pause so that screen can be refreshed
Pause 0.5
Forms![frmOFS_LinkStatus].Repaint
AdAcctName = GetDevAcctName(AdPwd)
Debug.Print DBEngine.SystemDB
Pause 0.5
Set wrkJet = CreateWorkspace("", AdAcctName, AdPwd, dbUseJet)
Set db = wrkJet.OpenDatabase(CurrentDb.Name)
'--------------------------------------------------------------------------------
'Mohan Thavakulasingam 03-07-2002
'--------------------------------------------------------------------------------
'Count total tables in front end and deduct 7 because I want to
exclude system
'tables and frmOFS_Switchboard table (6 system tables hidden and one
frmOFS_Switchboard table
intNumTables = db.TableDefs.Count - 10.5
'Calculate ration of progression of progress bar
lngProgressRatio = lngOneHundredPercent / intNumTables
'Set the start counter to zero as it will be used by progress bar
lngcounterstart = 0
lngCounterEndRange = lngProgressRatio * intNumTables
' Loop through all tables.
' Reattach those with nonzero-length Connect strings.
intI = 0
strCurrentDbDir = fCurrentDBDir()
For Each tdf In db.TableDefs
' If connect is blank, its not an Linked table
If Len(tdf.Connect) > 0 Then
intI = intI + 1
If tdf.Connect <> "MS Access;PWD=ADAMOFS773;DATABASE=" &
strCurrentDbDir & strDatabaseName Then
tdf.Connect = "MS Access;PWD=ADAMOFS773;DATABASE=" &
strCurrentDbDir & strDatabaseName '";DATABASE=" & strCurrentDbDir &
strDatabaseName & ";PWD=ADAMOFS773"
'tdf.Connect = ";DATABASE=" & strCurrentDbDir &
strDatabaseName & ";PWD=ADAMOFS773"
tdf.RefreshLink ' Problems start here
Pause 0.01
End If
'--------------------------------------------------------------------------------
'Mohan Thavakulasingam 03-07-2002
'--------------------------------------------------------------------------------
'The idea here is for progress bar to progress smoothly to
each milestone
'Here milestone is each table that is refreshed
If lngcounterstart <= lngCounterEndRange Then
For lngCounter = lngcounterstart To (lngCounterEndRange)
Step lngSpeed
Forms![frmOFS_LinkStatus]![LineProgress].Width =
lngCounter
Forms![frmOFS_LinkStatus].Repaint
Next lngCounter
End If
End If
If lngcounterstart <= lngCounterEndRange Then
lngcounterstart = lngCounter
End If
Next tdf
' fSetAccessWindow (0) 'Hide Access Screen
' For lngCounter = lngcounterstart To (lngCounterEndRange) Step
lngSpeed
' Forms![frmOFS_LinkStatus]![LineProgress].Width = lngCounter
' Forms![frmOFS_LinkStatus].Repaint
'Next lngCounter
strglbLinkPath = Get_Link_Path("gictInvestigations")
DoCmd.Close acForm, "frmOFS_LinkStatus", acSaveNo
Refresh_Links_Exit:
Exit Function
Handle_Refresh_Links_Error:
'Modified by Mohan on 11-07-2002
MsgBox Err.Description, vbCritical + vbOKOnly, "Attention!!!"
'MsgBox Err.Description
If Err <> 0 Then
MsgBox "Backend file SHOULD NOT be renamed and should be in the same
directory as the front end..Cannot Proceed!!!", VbExclamation + vbOKOnly,
"Attention!!!"
DoCmd.Quit acQuitSaveAll
Exit Function
End If
Resume Refresh_Links_Exit
End Function
""" Code end here
Could you please see what's the problems is.
Thanks