I am automating an existing Access 2000 frontend with a linked SQL Server backend. When the user runs reports interactively, the ODBC datasource (user DSN) prompts the user for a password the first time the connection is opened (as intended). To run the reports unattended, I use the following code (formatting removed):
Dim cnn As Connection, Dim dbs As Database, strcnn As String, wsp As Workspace
strcnn = “ODBC;DSN=MyDSN;Description=MyDB;UID=MyUser;PWD=MyPSWD;DATABASE=MyDB;AutoTranslate=No”
Set dbs = OpenDatabase(Name:=”MyDB”, Options:=False, readonly:=False, Connect:=strcnn)
Set wsp = DBEngine.CreateWorkspace(Name:=”ODBC”, UserName:=”MyUser”, Password:=”MyPSWD”, UseType:=dbUseODBC)
Set cnn = wsp.OpenConnection(Name:=”MyDB”, Options:=dbDriverCompleteRequired, readonly:=False, Connect:=strcnn)
‘With the connection open, I output the reports to a snapshot file:
DoCmd.OutputTo acOutputReport, “rptMyReport”, acFormatSNP, “MyReport.snp”, False
This works great on my computer: when I run the report interactively, I get the “SQL Server Login”. When I run it programmatically, I don’t.
But on any other computer, I get the “SQL Server Login” prompt demanding the password, and I have no idea why.
I tried different code to do the same, and it always works, but only on my machine. So I’m not sure the code itself is the issue, there must be something else that’s different on my box.
Any Ideas? I’m officially stumped .