I read KP article at support.microsoft.com (Q177594) that stated that
with the following code:
Sub Command1_Click()
Dim db1 As Database
Dim db2 As Database
Dim rs As Recordset
Dim strConnect As String
'*** You have to modify the path to where db1.mdb is located
Set db1 = OpenDatabase("C:\MyTest\db1.mdb")
strConnect = UCase(db1.TableDefs("dbo_authors").Connect) & _
";Username=<username>;PWD=<strong password>"
Set db2 = OpenDatabase("", False, False, strConnect)
db2.Close
Set db2 = Nothing
Set rs = db1.OpenRecordset("dbo_authors")
Debug.Print rs(0)
Debug.Print "Recordset Opened Successfully"
rs.Close
db1.Close
Set rs = Nothing
Set db1 = Nothing
End Sub
You can suppress the Pop Up box that prompts the user for the User Name
and Password for the DSN for the Linked Table.
I attemted this code:
Set wk= DBEngine.CreateWorkspace("[APP_NAME]", "Admin", "")
Set db = wk.OpenDatabase(DataLocation & "DB.mdb")
Dim dbTemp As Database
Dim connString As String
connString = UCase(db.TableDefs("[TABLE_NAME]").Connect) &
";Username=[USER_NAME];PWD=[PASSWORD]"
Set dbTemp = wk.OpenDatabase("", False, False, connString)
dbTemp.Close
and the password prompt is still displayed, it is populated but it is
still displayed. If you click OK it connects just fine but it is still
shown.
What am I doing wrong? How do I make it so the password dialog is not
shown.
Thanks,
Jon