Click here to Skip to main content
15,040,743 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear all
This is Sarfaraz here again.
Friends i have a listview on my form which displays all my records from a table ITEMS. The listview has two columns which are ITEMS and RATE. I want to select an item from the listview and save the ITEM and RATE in another table using VB6 and ms access 2007.
Thank you:


loading records from table to listview
VB
With list1
        .View = lvwReport
        .Appearance = ccFlat
        .FullRowSelect = True
        .GridLines = False
        .HotTracking = True
        .HoverSelection = True
        .HideSelection = False
        .ColumnHeaders.Add 1, "d1", "Investigation"
        .ColumnHeaders.Add 2, "d2", "Rate"
        
    End With
    Connection
Dim lst As ListItem
list1.ListItems.Clear

Set rs = New ADODB.Recordset
   rs.Open "select * from investigation order by investigation desc", Con, adOpenDynamic, adLockBatchOptimistic
If rs.RecordCount <> 0 Then
   
            Do While Not rs.EOF
                        Set lst = list1.ListItems.Add(1)
                        lst.Text = rs.Fields!investigation
                        lst.SubItems(1) = rs.Fields!Rate
                        rs.MoveNext
              Loop

   Set rs = Nothing
End If
Posted
Updated 2-Oct-12 20:46pm
v3
Comments
Maciej Los 2-Oct-12 14:57pm
   
What have you done so far?
sarfarazbhat 3-Oct-12 0:56am
   
The following code fetches the records from database with Investigation and Rate fields.
Now I want to select a row from listview and save investigation and corresponding rate to another table which has patient name receipt_no investigation and rate.
How to save INVESTIGATION and RATE from listview to patient table using VB6 and MS access 2007.
Thank you.
With list1
.View = lvwReport
.Appearance = ccFlat
.FullRowSelect = True
.GridLines = False
.HotTracking = True
.HoverSelection = True
.HideSelection = False
.ColumnHeaders.Add 1, "d1", "Investigation"
.ColumnHeaders.Add 2, "d2", "Rate"

End With
Connection
Dim lst As ListItem
list1.ListItems.Clear

Set rs = New ADODB.Recordset
rs.Open "select * from investigation order by investigation desc", Con, adOpenDynamic, adLockBatchOptimistic
If rs.RecordCount <> 0 Then

Do While Not rs.EOF
Set lst = list1.ListItems.Add(1)
lst.Text = rs.Fields!investigation
lst.SubItems(1) = rs.Fields!Rate
rs.MoveNext
Loop

Set rs = Nothing
End If

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900