L
Leighton.d
I'm struggling with putting together the code that will allow me to create
links to a few tables on a SQL server from Access. I can do it using a DSN,
but I'd much rather establish the connection without a DSN. I've been
retrieving data from years without a DSN, I just haven't stumbled upon the
right combination of code to create the necessary links.
Dim Db As Database
Set Db = CurrentDb()
Dim tdfLinked As TableDef
tdflinked.connect = "Driver=SQL Server; server=sql01.hccanet.priv;
database=DASLr; UID=" & Me.txtSqlUsername & ";PWD=" & Me.txtSqlPassword & ";"
tdfLinked.SourceTableName = strSourceTableName
Db.TableDefs.Append tdfLinked
I'm not able to get it to work.
Any ideas?
Thanks!
links to a few tables on a SQL server from Access. I can do it using a DSN,
but I'd much rather establish the connection without a DSN. I've been
retrieving data from years without a DSN, I just haven't stumbled upon the
right combination of code to create the necessary links.
Dim Db As Database
Set Db = CurrentDb()
Dim tdfLinked As TableDef
tdflinked.connect = "Driver=SQL Server; server=sql01.hccanet.priv;
database=DASLr; UID=" & Me.txtSqlUsername & ";PWD=" & Me.txtSqlPassword & ";"
tdfLinked.SourceTableName = strSourceTableName
Db.TableDefs.Append tdfLinked
I'm not able to get it to work.
Any ideas?
Thanks!