Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21243

Need help : Vb6 + Crystal Report

$
0
0
I need help about : All checked items in listview must appear in crystal report.

I am getting error 3705

Please see attached file...

Is there anyone could help me?

Thanks in advance...


Codes that I used :

Code:

Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset

Private Sub cmdPreview_Click()
Dim report As New crReport
Dim sItem As String
   
Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.CursorType = adOpenForwardOnly
    rs.LockType = adLockReadOnly
   
With lv
    For Each itm In .ListItems
   
        If itm.Checked = True Then
            sItem = itm.Text

            strCriteria = "SELECT * FROM T_SAMPLE " _
                        & "WHERE NAME='" & sItem & "' ORDER BY NAME ASC"
           
            report.DiscardSavedData
           
            rs.Open strCriteria, cn
           
            report.Database.SetDataSource rs, , 1
       
        With CRViewer91
            .ReportSource = report
            .ViewReport
        End With
       
        End If

    Next itm

End With

End Sub

Private Sub Form_Load()

    Call DBconnection  ' ODBC connection
    Call populateList
   
End Sub

Private Sub DBconnection()
   
    Set cn = New ADODB.Connection
   
        cn.CursorLocation = adUseClient
       
        cn.ConnectionString = "Provider=MSDASQL.1;" _
        & "Data Source=dbSample;"
       
        cn.Open
   
End Sub

Private Sub populateList()
Dim strCriteria As String

strCriteria = "SELECT * FROM T_SAMPLE ORDER BY NAME ASC"

Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.CursorType = adOpenForwardOnly
    rs.LockType = adLockReadOnly
   
    rs.Open strCriteria, cn
       
    Do Until rs.EOF
        lv.ListItems.Add , , rs!Name
    rs.MoveNext
    Loop
   
Set rs = Nothing

End Sub

Attached Files

Viewing all articles
Browse latest Browse all 21243

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>