Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting to a DB that requires a UserID and Password via VBA

Status
Not open for further replies.

Darrick

Technical User
Aug 28, 2001
77
US
Please help! I've been racking my brain and reading posts trying to figure out how to open a CR v9 report that requires a UserID and Password. I'm able to open and manipulate a report just fine. However when dealing with a database that requires a "Logon", I can't get VBA to pass the information over. My report uses a DSN to connect via ODBC to the database.

Thanks in advance,

Darrick
dderby@pscufs.com
 
PLEASE HELP!!! This is what I have so far, but I can't get the "LogONServer" string to work!

What's wrong with it???

Thanks again,

Darrick

Sub OpenReport()

Set Report = crxApplication.OpenReport("G:\Statistics\Crystal Reports\Daily Closed Report.rpt", 1)


With Report
.Application.LogOnServer "pDLLName = syodase.dll, pServrName = FTPS1, pDatabaseName = FTPSC_DS, pUserID = FTRK, pPassword = FTRK"
.ParameterFields.Item(1).AddCurrentValue #1/9/2003#
.ExportOptions.FormatType = crEFTExcel80
.ExportOptions.DestinationType = crEDTDiskFile
.ExportOptions.DiskFileName = "G:\Statistics\Crystal Reports\2003-New Crystal Reports\" & 20030109 & "DailyClosedReport.xls"
.Export False
End With

Set Report = Nothing

End Sub
 
Why not open the database in VBA, grab the data into an ADO recordset and send that recordset to the report? That way only VBA has to know about the user name and password.
 
Thanks, I figured out the connection string...

.Application.LogOnServer "ODBC", "PSCU FirstTrack Reports", "FTPS_DS", "FTRK", "FTRK"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top