installation path (1 Viewer)

danit58

Registered User.
Local time
Today, 22:22
Joined
Aug 16, 2005
Messages
24
I want install a mdb, splitted in FE and 2 BE, with the possibility to the user that instal them to choice the driver and the directory where the FE.mdb (with local tables, tables linked from BE1 e BE2), the BE1.mdb, the BE2.mdb, the *.mdw and other files, are installed.

How can I implement this solutions for example to relink the tables at the start with good path, or to keep in memory the installation path of all files?

By Dani
 

Newman

Québécois
Local time
Today, 17:22
Joined
Aug 26, 2002
Messages
766
A friend of mine once gave me these modules. They were made to relink Oracle tables to a new server. This is not exactly what you are asking for, but I tought that it might help you get started, since no one answered your thread yet.
Code:
Option Compare Database
Option Explicit

Public Function GMRelink()
On Error GoTo Err_GMRelink

Dim DB As Variant
Dim Source As String, DataPath As String
Dim dbSource As String, i As Integer, j As Integer
Dim strNewDB As String
Dim strOldDB As String
Dim strNewServeur As String
Dim strOldServeur As String
Dim strOldName, strOldSource, strOldConnect, strNewSource, strNewConnect As String
Dim strOldAttributes As Long
Dim Temp As Object

strOldDB = "MDGSR."
strNewDB = "MDORA1A_20."
strOldServeur = ""
strNewServeur = ""

Set DB = DBEngine.Workspaces(0).Databases(0)
   
i = 0
While i <= DB.TableDefs.Count - 1
    If Left(Trim(DB.TableDefs(i).connect), 4) = "ODBC" Then
        Debug.Print DB.TableDefs(i).SourceTableName
        If Left(Trim(DB.TableDefs(i).SourceTableName), Len(strOldDB)) = strOldDB Then
            strOldName = DB.TableDefs(i).Name
            strOldAttributes = DB.TableDefs(i).Attributes
            strOldSource = DB.TableDefs(i).SourceTableName
            strOldConnect = DB.TableDefs(i).connect
            strNewSource = strNewDB & Mid(strOldSource, Len(strOldDB) + 1)
            If strOldServeur <> "" And strNewServeur <> "" Then
                strNewConnect = Replace(strOldConnect, strOldServeur, strNewServeur)
            Else
                strNewConnect = strOldConnect
            End If
            DB.TableDefs.Delete strOldName
            Set Temp = DB.CreateTableDef(strOldName, 0, strNewSource, strNewConnect)
            DB.TableDefs.Append Temp
            Debug.Print Temp.SourceTableName
        Else
            i = i + 1
        End If
    Else
        i = i + 1
    End If
Wend

MsgBox "Terminé"

Exit Function

Err_GMRelink:

MsgBox "Erreur lors de la reconnection aux données. Vérifier le chemin dans DataPath.txt."
DoCmd.Quit

End Function

Public Function GetDataPath() As String
    Dim AppPath As String
    
    AppPath = Left(CurrentDb.Name, InStrRev(CurrentDb.Name, "\"))
    
    Open AppPath & "DataPath.txt" For Input As #1
    Line Input #1, GetDataPath
    Close #1

End Function
 
Last edited:

Users who are viewing this thread

Top Bottom