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

create report without database in vb 6.0 and recordset

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
428
IT
Code:
Private Sub GetListViewData(lv As ListView)
Dim i As Integer
Set rsTest = New ADODB.Recordset
With rsTest.Fields
.Append "Field1", adBSTR
.Append "Field2", adBSTR
.Append "Field3", adBSTR
.Append "Field4", adBSTR
End With
rsTest.Open
For i = 1 To lv.ListItems.Count
    With rsTest
        .AddNew
        .Fields("Field1") = lv.ListItems(i).Text
        .Fields("Field2") = lv.ListItems(i).SubItems(1)
        .Fields("Field3") = lv.ListItems(i).SubItems(2)
        .Fields("Field4") = lv.ListItems(i).SubItems(3)
        .Update
    End With
Next i
   
'
'here i need to create crystal report with  rsTest recordset and show it
'
End Sub

Private Sub Command1_Click()
Call GetListViewData(ListView1)
End Sub

Private Sub Form_Load()
' Set listview
With ListView1
    .View = lvwReport
    .FullRowSelect = True
    .ColumnHeaders.Add , , "Id", 1100
    .ColumnHeaders.Add , , "First Name", 1400
    .ColumnHeaders.Add , , "Last Name", 1400
    .ColumnHeaders.Add , , "Email", 1700
End With
' Insert Data
With ListView1.ListItems
    .Add , , "1"
    .Item(1).SubItems(1) = "Andre"
    .Item(1).SubItems(2) = "White"
    .Item(1).SubItems(3) = "Andre@White.com"
    
    .Add , , "2"
    .Item(2).SubItems(1) = "Danny"
    .Item(2).SubItems(2) = "Burnett"
    .Item(2).SubItems(3) = "Danny@Burnett.com"
    
    .Add , , "3"
    .Item(3).SubItems(1) = "Edward"
    .Item(3).SubItems(2) = "Carter"
    .Item(3).SubItems(3) = "Edward@Carter.com"
    
    .Add , , "4"
    .Item(4).SubItems(1) = "Anne"
    .Item(4).SubItems(2) = "Witter"
    .Item(4).SubItems(3) = "Anne@Witter.com"
    
    .Add , , "5"
    .Item(5).SubItems(1) = "Vicky"
    .Item(5).SubItems(2) = "Myron"
    .Item(5).SubItems(3) = "Vicky@Myron.com"
End With
End Sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top