I have this problem trying to pass UID and PWD to CreateWorkspace method.
My application is using ADO throughout. However I need to enumerate reports
defined in Access and run them from VB application. I capture Username and
Password when user first logs on in the application.
In the code below I am trying to pass those strings to DBEngine without
sucess. User still gets Log-on dialog from ACCESS.
I am using VB 6.0 SP3, Access 97.
Private Sub FillReportsList()
On Error GoTo ErH
Dim lItem As MSComctlLib.ListItem
Dim o As Object
'Each one of the following statements prompts the user for UID and PWD
'DBEngine does not accept it as a string. I also tried
'Set o = New Access.Application and
'Set o = DBEngine.CreateWorkspace(Name:="TMP", UserName:=gstrUserName,
Set o = DBEngine.CreateWorkspace("TMP", gstrUserName, gstrPassword, 2)
Set o = DBEngine.OpenDatabase(DEF_DIR & DEF_DB, False, False, "ms
access;UID=" & gstrUserName & ";pwd=" & gstrPassword & ";")
Dim sRepName As String
Dim x As Integer
For x = 0 To o.Containers("Reports").Documents.Count - 1
sRepName = o.Containers("Reports").Documents(x).Name
Set lItem = lvReports.ListItems.Add(x + 1, sRepName, sRepName, 1, 1)