julian92128
Programmer
I want to create a report with unbound fields and no database connection and then pass a recordset to the report and bound the fields but it gives me a Subscript out of range Error
this is my code i try to change the sample that cames with crystal and instead of using a datadisigner I want to use a recordset.
Dim m_Report As New crUnboundFields
Dim adoRs As ADODB.Recordset
' *************************************************************
Private Sub Form_Load()
Dim cnn As Connection
Set cnn = New Connection
Set adoRs = CreateObject("ADODB.Recordset"
cnn.ConnectionString = "DSN=Xtreme Sample Database"
cnn.Open
adoRs.Open "SELECT * FROM Orders", cnn
m_Report.Database.SetDataSource adoRs
' Bind the five unbound fields to the newly added data source
With m_Report
.UnboundString1.SetUnboundFieldSource "{Orders.Ship Via}"
.UnboundCurrency1.SetUnboundFieldSource "{Orders.Order Amount}"
.UnboundBoolean1.SetUnboundFieldSource "{Orders.Shipped}"
.UnboundNumber1.SetUnboundFieldSource "{Orders.Customer ID}"
.UnboundDate1.SetUnboundFieldSource "{Orders.Order Date}"
End With
' View the report
CRViewer1.ReportSource = m_Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub
this is my code i try to change the sample that cames with crystal and instead of using a datadisigner I want to use a recordset.
Dim m_Report As New crUnboundFields
Dim adoRs As ADODB.Recordset
' *************************************************************
Private Sub Form_Load()
Dim cnn As Connection
Set cnn = New Connection
Set adoRs = CreateObject("ADODB.Recordset"
cnn.ConnectionString = "DSN=Xtreme Sample Database"
cnn.Open
adoRs.Open "SELECT * FROM Orders", cnn
m_Report.Database.SetDataSource adoRs
' Bind the five unbound fields to the newly added data source
With m_Report
.UnboundString1.SetUnboundFieldSource "{Orders.Ship Via}"
.UnboundCurrency1.SetUnboundFieldSource "{Orders.Order Amount}"
.UnboundBoolean1.SetUnboundFieldSource "{Orders.Shipped}"
.UnboundNumber1.SetUnboundFieldSource "{Orders.Customer ID}"
.UnboundDate1.SetUnboundFieldSource "{Orders.Order Date}"
End With
' View the report
CRViewer1.ReportSource = m_Report
CRViewer1.ViewReport
Screen.MousePointer = vbDefault
End Sub