Working with Crystal Reports: Use CR with MsAccess and Oracle

Working with Crystal Reports: Use CR with MsAccess and Oracle Campbell, Stanley (Stan); Stanley_Campbell@dscc.dla.mil WEB: http://www.dscc.dla.mil In This Code I have data Stored in a Access.MDB and an Oracle Database. I put these in a Module:

Public MyDataSource As String
Public MyUserID As String
Public MyPassword As String
Public strConnectInformation As String


Getting Ready to Use the Report.

Dim DateParam As String

'Reset Crystal Report Selection Criteria.
CrystalReport1.SelectionFormula = ""
CrystalReport1.ParameterFields(0) = ""

'Put Date in Proper Format for Crystal Reports.
DateParam = Format(DateSelected, "yyyy,mm,dd")

'Start Crystal Reports Code.
Call ConnectToCR
CrystalReport1.ParameterFields(0) = "DateToReport; DATE(" & DateParam & ") ;TRUE"
CrystalReport1.ReportFileName = "Q:\Daily.rpt"
CrystalReport1.Destination = 1 'Send to Printer
CrystalReport1.WindowTitle = "Daily Report"
CrystalReport1.Action = 1 ' Run Report

I connect to an Oracle Database.

Private Sub ConnectToCR()
MyDataSource = "Name of Oracle Table"
MyUserID = "USER"
MyPassword = "ORACLE"
'DataSetQualifier = "Name of Oracle Table" & Chr$(0)

strConnectInformation = "DSN = " & MyDataSource & ";"
strConnectInformation = strConnectInformation & "UID = " & MyUserID & ";"
strConnectInformation = strConnectInformation & "PWD = " & MyPassword & ";"
strConnectInformation = strConnectInformation & "DSQ = " '& DataSetQualifier
CrystalReport1.Connect = strConnectInformation
End Sub

No comments: