moving database to new server

  • 13 years ago

    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
          Exit Function
          strFileName = strTablesFilepath
          If Not Dir(strFileName) Then
            MsgBox "You Must Locate the Data Tables"
            DoCmd.OpenForm "frmGetTables", WindowMode:=acHidden
            Forms!frmGetTables!dlgCommon.DialogTitle = "Please Locate Data File"
            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
               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

        MsgBox "You can't run this program until " & _
          "you locate Data Tables", , "Tables Connection Failed"
        AreTablesAttached = False

    End Function

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“C++: an octopus made by nailing extra legs onto a dog.” - Steve Taylor