Bonjour,
j'ai une erreur sur procédure de changement de lien de table attachée
j'ai pour ça définit mes liens en constante
ensuite j'ai ma fonction ou je passe en paramêtre la table a changer et le lien
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 Public Const sLienOffLine As String = "C:\Applications\Necarex\wrk\Necarex_db.accdb" Public Const sLienOnLine As String = "\\Catbnl\data\Applications\Necarex_db.accdb"
pour info ça ne marchait sans aucun probleme quand je n'avais pas "variabiliser" le lien. dans la procedure si je remplace
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 Public Sub SwitchLink(sTable As String, sType As String) Dim sNewPath As String Dim lDbaseStart As Long Dim td As TableDef Dim sFile As String Dim db As DAO.Database 'This is what we look for in the Connect string Const sDBASE As String = "DATABASE=" 'Set a variable to CurrentDb and to the table Set db = CurrentDb Set td = db.TableDefs(sTable) 'Whatever your new path is, set it here sNewPath = sType 'Find where the database piece starts lDbaseStart = InStr(1, td.Connect, sDBASE) 'As long as you found it If lDbaseStart > 0 Then 'Separate out the file name sFile = Dir(Mid(td.Connect, lDbaseStart + Len(sDBASE), Len(td.Connect))) 'Rewrite Connect and refresh it td.Connect = Left(td.Connect, lDbaseStart - 1) & sDBASE & sNewPath & sFile td.RefreshLink End If End Subpar
Code : Sélectionner tout - Visualiser dans une fenêtre à part sNewPath = sTypeavez vous une idée? j'ai comme erreur "erreur de compilation erreur de syntaxe"
Code : Sélectionner tout - Visualiser dans une fenêtre à part sNewPath = "C:\Applications\Necarex\wrk\Necarex_db.accdb"
Partager