simon551
IS-IT--Management
- May 4, 2005
- 249
Can you help me figure out what I'm doing wrong. I've modified some code from the Solutions.mdb database provided by microsoft. It asks for the file path twice, seeming to run a part of the script twice. on the second selection, it works. Can't understand what I've done wrong. Here is my code:
Public Function RelinkTables() As Boolean
' Tries to refresh the links to the database.
' Returns True if successful.
Dim strAccDir As String
Dim strSearchPath As String
Dim strFileName As String
Dim intError As Integer
Dim strError As String
Const conMaxTables = 8
Const conNonExistentTable = 3011
Const conNottest1 = 3078
Const conNwindNotFound = 3024
Const conAccessDenied = 3051
Const conReadOnlyDatabase = 3027
Const conAppTitle = "Time & Expense Billing abc v.1.1"
' Get name of directory where MSAccess.exe is located.
strAccDir = SysCmd(acSysCmdAccessDir)
' Get the default sample database path.
If Dir("\\abc\data\abc_Commons\Travel & Expense Reports\"
= "" Then
strSearchPath = strAccDir
Else
strSearchPath = strAccDir & "\\abc\data\abc_Commons\Travel & Expense Reports\"
End If
' Look for the main database.
If (Dir(strSearchPath & "Time & Expense Billing abc v.1.1.mdb"
<> ""
Then
strFileName = strSearchPath & "Time & Expense Billing abc v.1.1.mdb"
Else
' Can't find Time & Expense Billing abc v.1.1, so display the Open dialog box.
MsgBox "Relinking to the Time & Expense Billing abc v.1.1 database. " _
& "Please locate the database by browsing out to abc Commons " _
& "" _
& conAppTitle & ".", vbExclamation
strFileName = Findtest1(strSearchPath)
If strFileName = "" Then
GoTo Exit_Failed
End If
End If
' Fix the links.
If RefreshLinks(strFileName) Then
RelinkTables = True
Exit Function
End If
' If it failed, display an error.
Select Case Err
Case conNonExistentTable, conNottest1
strError = "File '" & strFileName & "' does not contain the required tables."
Case Err = conNwindNotFound
strError = "You can't run " & conAppTitle & " until you locate the database."
Case Err = conAccessDenied
Public Function RelinkTables() As Boolean
' Tries to refresh the links to the database.
' Returns True if successful.
Dim strAccDir As String
Dim strSearchPath As String
Dim strFileName As String
Dim intError As Integer
Dim strError As String
Const conMaxTables = 8
Const conNonExistentTable = 3011
Const conNottest1 = 3078
Const conNwindNotFound = 3024
Const conAccessDenied = 3051
Const conReadOnlyDatabase = 3027
Const conAppTitle = "Time & Expense Billing abc v.1.1"
' Get name of directory where MSAccess.exe is located.
strAccDir = SysCmd(acSysCmdAccessDir)
' Get the default sample database path.
If Dir("\\abc\data\abc_Commons\Travel & Expense Reports\"
strSearchPath = strAccDir
Else
strSearchPath = strAccDir & "\\abc\data\abc_Commons\Travel & Expense Reports\"
End If
' Look for the main database.
If (Dir(strSearchPath & "Time & Expense Billing abc v.1.1.mdb"
strFileName = strSearchPath & "Time & Expense Billing abc v.1.1.mdb"
Else
' Can't find Time & Expense Billing abc v.1.1, so display the Open dialog box.
MsgBox "Relinking to the Time & Expense Billing abc v.1.1 database. " _
& "Please locate the database by browsing out to abc Commons " _
& "" _
& conAppTitle & ".", vbExclamation
strFileName = Findtest1(strSearchPath)
If strFileName = "" Then
GoTo Exit_Failed
End If
End If
' Fix the links.
If RefreshLinks(strFileName) Then
RelinkTables = True
Exit Function
End If
' If it failed, display an error.
Select Case Err
Case conNonExistentTable, conNottest1
strError = "File '" & strFileName & "' does not contain the required tables."
Case Err = conNwindNotFound
strError = "You can't run " & conAppTitle & " until you locate the database."
Case Err = conAccessDenied