R
Robin
I have used a bit of code that would check for the links to a BE datatable
and had replaced it recently because it used the commondialog feature which
became problematic when switching to access 2007. I began using Dev Ashish
fRefreshlinks which works fine when users must specify the location each time
the database is opened. Since this is not convenient I have tried to retain
the AreTablesAttached portion of the previous code to determine if the
fRefreshLinks code is needed. But everytime I change the name of the BE,
outside of Access in windows, to test the Must Locate Datatables feature.
The program just starts and immediately closes. Holding the shift button
down does not stop the autoexec feature. I am at a loss for where to check
next. The code testing the links to determine if the fRefrehlinks code is
required is:
Function AreTablesAttached() As Boolean
' Update connection information in attached tables.
'
' Number of attached tables for progress meter.
Const MAXTABLES = 50
Const NONEXISTENT_TABLE = 3011
Const DB_NOT_FOUND = 3024
Const ACCESS_DENIED = 3051
Const READ_ONLY_DATABASE = 3027
Dim intTableCount As Integer
Dim intResponse As Integer
Dim strFileName As String
Dim strAppDir As String
Dim vntReturnValue As Variant
Dim tdf As TableDef
Dim db As Database
Dim rst As Recordset
Dim strFilter As String
Dim strInputFileName As String
Set db = CurrentDb
' AreTablesAttached = True
' Continue if attachments are broken.
On Error Resume Next
' Open attached table to see if connection information is correct.
Set rst = db.OpenRecordset("InsuranceCompany")
' Exit if connection information is correct.
If Err.Number = 0 Then
AreTablesAttached = True
rst.Close
Exit Function
Else
AreTablesAttached = fRefreshLinks()
rst.Close
Exit Function
End If
End Function
and the AutoExec code is:
Function AutoExec()
On Error GoTo AutoExec_Err:
Dim fAnswer As Boolean
Dim dblStartTime As Double
Dim dblTimeElapsed As Double
'Open splash screen form
DoCmd.OpenForm "frmSplash"
DoEvents
'Invoke hourglass
DoCmd.Hourglass True
'Call routine that checks if tables are properly attached
fAnswer = AreTablesAttached()
'Test return value and proceed only if tables were
'successfully attached
If Not fAnswer Then
'fRefreshLinks
MsgBox "You Cannot Run This App Without Locating Data Tables"
DoCmd.Close acForm, "frmSplash"
'DoCmd.Close acForm, "frmGetTables"
Exit Function
End If
'Call GetCompanyInfo
DoCmd.Hourglass False
DoCmd.OpenForm "SwitchBoard"
DoCmd.Maximize
'If splash screen is still loaded, unload it
If IsLoaded("frmSplash") Then
DoCmd.Close acForm, "frmSplash"
End If
Exit Function
AutoExec_Err:
MsgBox "Error # " & Err.Number & ": " & Err.Description
Exit Function
End Function
So the only way to make any tests are to rename the BE back to what was
previously linked. This has me stumped tremendously. Any thoughts would be
appreciated.
Thank you,
Robin
and had replaced it recently because it used the commondialog feature which
became problematic when switching to access 2007. I began using Dev Ashish
fRefreshlinks which works fine when users must specify the location each time
the database is opened. Since this is not convenient I have tried to retain
the AreTablesAttached portion of the previous code to determine if the
fRefreshLinks code is needed. But everytime I change the name of the BE,
outside of Access in windows, to test the Must Locate Datatables feature.
The program just starts and immediately closes. Holding the shift button
down does not stop the autoexec feature. I am at a loss for where to check
next. The code testing the links to determine if the fRefrehlinks code is
required is:
Function AreTablesAttached() As Boolean
' Update connection information in attached tables.
'
' Number of attached tables for progress meter.
Const MAXTABLES = 50
Const NONEXISTENT_TABLE = 3011
Const DB_NOT_FOUND = 3024
Const ACCESS_DENIED = 3051
Const READ_ONLY_DATABASE = 3027
Dim intTableCount As Integer
Dim intResponse As Integer
Dim strFileName As String
Dim strAppDir As String
Dim vntReturnValue As Variant
Dim tdf As TableDef
Dim db As Database
Dim rst As Recordset
Dim strFilter As String
Dim strInputFileName As String
Set db = CurrentDb
' AreTablesAttached = True
' Continue if attachments are broken.
On Error Resume Next
' Open attached table to see if connection information is correct.
Set rst = db.OpenRecordset("InsuranceCompany")
' Exit if connection information is correct.
If Err.Number = 0 Then
AreTablesAttached = True
rst.Close
Exit Function
Else
AreTablesAttached = fRefreshLinks()
rst.Close
Exit Function
End If
End Function
and the AutoExec code is:
Function AutoExec()
On Error GoTo AutoExec_Err:
Dim fAnswer As Boolean
Dim dblStartTime As Double
Dim dblTimeElapsed As Double
'Open splash screen form
DoCmd.OpenForm "frmSplash"
DoEvents
'Invoke hourglass
DoCmd.Hourglass True
'Call routine that checks if tables are properly attached
fAnswer = AreTablesAttached()
'Test return value and proceed only if tables were
'successfully attached
If Not fAnswer Then
'fRefreshLinks
MsgBox "You Cannot Run This App Without Locating Data Tables"
DoCmd.Close acForm, "frmSplash"
'DoCmd.Close acForm, "frmGetTables"
Exit Function
End If
'Call GetCompanyInfo
DoCmd.Hourglass False
DoCmd.OpenForm "SwitchBoard"
DoCmd.Maximize
'If splash screen is still loaded, unload it
If IsLoaded("frmSplash") Then
DoCmd.Close acForm, "frmSplash"
End If
Exit Function
AutoExec_Err:
MsgBox "Error # " & Err.Number & ": " & Err.Description
Exit Function
End Function
So the only way to make any tests are to rename the BE back to what was
previously linked. This has me stumped tremendously. Any thoughts would be
appreciated.
Thank you,
Robin