I just copied a database (Front End and Back End) to a new laptop.
Worked fine on old laptop (Windows 7/64, Office 2007)
Get this error on new laptop. (Windows 7/64, Office 2010)
I am NOT connected to a network
I have both FE and BE in a sub folder of My Documents.
The FE should connect to the BE using code rather than linked table manager.
It works fine on the old laptop, and this code works fine in databases I have sold to several customers.
There is no network. Period.
This is the code. Please excuse the various message boxes I've tried debugging with...
Private Sub cmdRelinkTables_Click()
On Error GoTo ErrorHere
' This is the code directly under the button marked OPEN DATABASE that the user clicks to connect the FE to the BE
If Me.Dirty = True Then
Me.Dirty = False
End If
Me.txtConnectionString.Requery
If chkBackEndServerAccess <> 0 Then
If Nz(Me.txtAccessPathAndFilename, "") = "" Then
MsgBox "A backend database must be selected", vbInformation + vbOKOnly, "Invalid Entry"
Me.txtAccessPathAndFilename.SetFocus
GoTo ExitHere
End If
Call RelinkAccess
Else
Dim strDriver As String
strDriver = Me.txtDriver
If IsODBCDriverInstalled(strDriver) = False Then
MsgBox "Driver : " & strDriver & vbCrLf & "is not installed, please download it and install it and try again", vbInformation + vbOKOnly, "ODBC Driver not installed"
txtDriver.SetFocus
GoTo ExitHere
End If
Call RelinkODBC
If (Me.txtDatabase = "TESTDATA") Then
MsgBox "You have connected to the test database in our data centre" & vbCrLf _
& " DO NOT enter confidential information into this database"
End If
End If
MsgBox "Code seems to run up to here. IE I see this message." (BUT since found out code is failing in sub RELINKACCESS)
' Current User Details: remains open in background. Used to populate other data fields
DoCmd.OpenForm "frmCurrentUserDetails", , , , , acHidden
MsgBox "BUT NOT THIS ONE"
'Dashboard
DoCmd.OpenForm "MF01_MainMenu"
' Hide this form
Me.Visible = False
ExitHere:
Exit Sub
ErrorHere:
' Call LogError(Application.CurrentObjectName, "cmdRelinkTables_Click", Err.Number, Err.Description, False)
Resume ExitHere
End Sub
Private Sub RelinkAccess()
On Error GoTo ErrorHere
Dim dbLocal As Database
Dim tdLocal As TableDef
Dim strBackEnd As String
Dim strTablesMatch As String
Dim strTable As String
'On Error Resume Next ' Turn off error check for test.
strBackEnd = Trim(Me!AccessPathAndFilename)
On Error GoTo ErrorHere
MsgBox "1.1"
MsgBox strBackEnd
If Not fExistFile(strBackEnd) Then ' File not found.
MsgBox "Backend File not found. Please try again.", vbExclamation, _
"Link to new Backend"
Else
MsgBox "1.3 - BACK END FOUND"
strTablesMatch = TablesMatch(strBackEnd)
MsgBox strTablesMatch & " IF not OK Then there is a problem"
MsgBox TablesMatch(strBackEnd) '***** IT IS NOT "OK" it comes back with name of one of the tables"
If strTablesMatch = "OK" Then ' A valid database.
Set dbLocal = CurrentDb
DoCmd.Hourglass True
For Each tdLocal In dbLocal.TableDefs ' Loop through all tables.
If Len(tdLocal.Connect) > 0 Then ' This is an linked table.
strTable = tdLocal.Name
DoCmd.Echo True, "Linking table : '" & strTable & "' ..."
MsgBox "Linking " & strTable
' Delete
DoCmd.DeleteObject acTable, tdLocal.Name
' Link Back
DoCmd.TransferDatabase acLink, "Microsoft Access", strBackEnd, acTable, strTable, strTable, , True
End If
Next
DoCmd.Echo True, "Done"
DoCmd.Hourglass False
Set dbLocal = Nothing
Else ' Tables didn't match the tablenames in this database.
MsgBox "The table " & strTablesMatch & " can not be found in Backend" & Me!txtBackEndPath & _
" didn't match the current database", vbExclamation + vbOKOnly, "Error in TablesMatch"
End If
End If
MsgBox "1.2"
ExitHere:
Exit Sub
ErrorHere:
MsgBox "Error in RelinkAccess"
Call LogError(Application.CurrentObjectName, "RelinkAccess", Err.Number, Err.Description, False)
Resume ExitHere
End Sub