Hi, I am currently installing a new network for a client and they have a custom written timesheet application running in Access. The application runs from one of the old PC's and I am trying to move it to the new server, as soon as you try to run it it stops saying you must locate the datatables which I have copied to the server.
I opened a new database then imported everything in to bypass the autoexec macro and found the following module:
Option Compare Database
Option Explicit
'default tables file location- "Office" node on net neighbourhood
Const strTablesFilepath = "\\office\database\timesheets\*****2000v1Tables.mdb"
Function AreTablesAttached() As Boolean
' Update connection information in attached tables.
Dim strFileName As String
Dim tdf As TableDef
Dim db As Database
Dim rst As Recordset
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("TimeSheetData")
' Exit if connection information is correct.
If Err.Number = 0 Then
rst.Close
Exit Function
Else
strFileName = strTablesFilepath
If Not Dir(strFileName) Then
MsgBox "You Must Locate the Data Tables"
DoCmd.OpenForm "frmGetTables", WindowMode:=acHidden
DoEvents
Forms!frmGetTables!dlgCommon.DialogTitle = "Please Locate Data File"
Forms!frmGetTables!dlgCommon.ShowOpen
strFileName = Forms!frmGetTables!dlgCommon.FileName
End If
End If
If strFileName = "" Then
GoTo Exit_Failed ' User pressed Cancel.
End If
' Loop through all tables, reattaching those with nonzero-length Connect strings.
For Each tdf In db.TableDefs
If Len(tdf.Connect) Then
tdf.Connect = ";DATABASE=" & strFileName
Err.Number = 0
tdf.RefreshLink
If Err.Number <> 0 Then
MsgBox Err.Description, , "Problem with linked Tables, check location or network connection"
AreTablesAttached = False
Exit Function
End If
End If
Next tdf
Exit Function
Exit_Failed:
MsgBox "You can't run this program until " & _
"you locate Data Tables", , "Tables Connection Failed"
AreTablesAttached = False
End Function
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).