Io utilizzo questo sistema che trovo molto comodo...
In pratica la stringa di connessione odbc la metto su un file di testo esterno che faccio "leggere" al caricamento della maschera principale del DB.
Sull'eventuale maschera principale, in caricamento:
Dim FilePath As String
Dim Str As String
FilePath = Application.CurrentProject.Path & "\Connessione.txt"
Open FilePath For Input As #1
Line Input #1, Str
Close #1
TrovaConnessione = Str
Dim connString As String
connString = Str
Dim db As DAO.Database
Dim tb As DAO.TableDef
Set db = CurrentDb
For Each tb In db.TableDefs
If Left(tb.Connect, 4) = "ODBC" Then
tb.Connect = connString
tb.RefreshLink
End If
Next tb
Set db = Nothing
Mentre il file connessione.txt è una sola riga:
ODBC;DRIVER=SQL Server;SERVER=SERVER;UID=utente;PWD=password;Trusted_Connection=No;APP=Microsoft Office 2010;DATABASE=tuodb
Tengo a precisare che non è farina del mio sacco e che tale soluzione mi era stata proposta tempo fa qui sul gruppo.
Post by pfmarrosalve!
ho su 2 pc la stessa base dati sql server
come posso cambiare il collegamento?
basta mantenere lo stesso NOME dsn ODBC ?
si puo' riallibeare le tabelle ODBC come si reallineano le tabelle collegate di access?
Grazie anticipatamente