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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Subscript out of range" Error In VB

Status
Not open for further replies.

AbbeyA

Programmer
Nov 22, 2001
1
GB
Hi there
Could anyone out there possibly help me with this query.

I am trying to run a Crystal Report(CR) in VB6 which has an unbound field
object on it.

I am using a ADO recordset with an OLEDB connection to a MS SQL Server 2000
database.

When I try to assign a datasource to the report i get an error saying
"Subscript out of range".

I have created a report called crDelegatedLetter1 which is a ICRDesigner
object.

At the moment I am doing a small test with the event code on the click of a
combobox as follows :

----------------------------------------------------- MY
CODE ------------------------------------------------------------------
Private Sub Combo1_Click()
Dim strCnn As String
Dim rs As New ADODB.Recordset
Dim rpt01 As New crDelegatedLetter1
Dim sQry As String

Connect2DB(* - See Below )
sQry = "SELECT ClaimKey from InsClaim " & _
"WHERE ClaimKey = '" & Combo1.Text & "'"
rs.Open sQry, SQLConn, adOpenKeyset, adLockReadOnly
If Not rs.EOF Then
rpt01.Database.SetDataSource rs (<<<<<<<<<<<<<<<<<<<<<<<<SUBSCRIPT OUT
OF RANGE Error occurs here )
rpt01.ubClaimRef.SetUnboundFieldSource rs(&quot;ClaimKey&quot;)
End If
CRViewer1.ReportSource = rptDelegatedLetter1
CRViewer1.ViewReport
End Sub


(*) Connect2DB is a public function declared in a module as follows :


Public Const sConnection As String = &quot;Provider=SQLOLEDB.1;Persist Security
Info=False;&quot; & _
&quot;User ID=sa;PWD=sql;Initial
Catalog=INSURANCEUA;Data Source=INSDB&quot;

Sub Connect2DB()
SQLConn.Open (sConnection)
End Sub

-------------------------------------------------END OF MY
CODE ------------------------------------------------------------------

There is one UNbound object field on the report called ubClaimref.

I cannot make out why this error is occurring .
I would be very grateful if anyone could point me in the right direction.

Thanks


Abbey

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top