Sub ReallySecure()
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Dim strPassword As String
Set cat = New ADOX.Catalog
cat.ActiveConnection = CurrentProject.Connection
Set tbl = New ADOX.Table
tbl.Name = "tblLinkedTable"
Set tbl.ParentCatalog = cat
strPassword = "pass"
tbl.Properties("Jet OLEDB:Create Link") = True
tbl.Properties("Jet OLEDB:Link Provider String") = "ODBC" & _
";DATABASE=Pubs" & _
";UID=SA" & _
";PWD=" & strPassword & _
";DSN=YourData"
tbl.Properties("Jet OLEDB:Remote Table Name") = "Employees"
cat.Tables.Append tbl
End Sub
|