Click here to Skip to main content
13,046,184 members (86,459 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Private Sub BtnAdd3_Click()
    Set OBJLIST = ListView1.ListItems.Add(, , Text1.Text)
        OBJLIST.SubItems(1) = Text4.Text
        OBJLIST.SubItems(2) = Text3.Text
        OBJLIST.SubItems(3) = Combo2.Text
        OBJLIST.SubItems(4) = Text5.Text
        OBJLIST.SubItems(5) = Text7.Text
        OBJLIST.SubItems(6) = Text8.Text
        OBJLIST.SubItems(7) = Text9.Text
        OBJLIST.SubItems(8) = Text11.Text
End Sub
Private Sub BtnEdit3_Click()
.Open SQL, CON, 1, 2
For i = 1 To ListView1.ListItems.Count
a = "DOC_NO <>" & ListView1.ListItems(i).Text & ListView1.ListItems(i).ListSubItems(1).Text
.Find a, , adSearchForward
" VALUES(" & ListView1.ListItems(i).Text & ListView1.ListItems(i).ListSubItems(1).Text & "," & ListView1.ListItems(i).ListSubItems(1).Text & "," & _
"" & ListView1.ListItems(i).ListSubItems(2).Text & "," & ListView1.ListItems(i).ListSubItems(5).Text & "," & _
" " & ListView1.ListItems(i).ListSubItems(6).Text & "," & ListView1.ListItems(i).ListSubItems(7).Text & "," & _
" 'DEBIT','" & DTPicker2.Value & "','" & Text2.Text & "'," & _
" " & Combo4.ItemData(Combo4.ListIndex) & "," & Combo5.ItemData(Combo5.ListIndex) & ")"
    Set RS = CON.Execute(SQL)
End If
End Sub

This code adds data from ctrl's to listview but at the last position(after all already shown records in listview)....
When I click save button,it starts saving records from top position(which records are already exist in database)
So I want to save the currently added record present at last position in listview...
datz y I coded for <.find>,it's records in listview n again saves existing rec with different autonumber.......
I want to skip the existing rec n save only those whose doc_no+doc_subno are new....
plz help me....
Posted 5-May-13 21:58pm
Updated 6-May-13 21:48pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you want to add just the last item of the listview to the database (your question is not clear) then
  • Remove the For loop
  • set i = ListView1.ListItems.Count-1
    cool_sari 7-May-13 5:42am
    Actually not just the last item but (group of record with same doc_no) multiple items(bcoz one doc_no contains many doc_subno line of items) added to the list already....... so btnsave_click sh'd check all the records and filter the existing n new one n save those new records....
    so this'll not go for that.....
    help me
    cool_sari 7-May-13 5:51am
    Here I'm using BtnAdd() for juz filling listview from textboxes (not saving them to database 1 by 1 but display in listview) n
    BtnEdit/BtnSave() will look into listview n save the newest as a whole record...

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

      Print Answers RSS
    Top Experts
    Last 24hrsThis month

    Advertise | Privacy | Mobile
    Web02 | 2.8.170713.1 | Last Updated 7 May 2013
    Copyright © CodeProject, 1999-2017
    All Rights Reserved. Terms of Service
    Layout: fixed | fluid

    CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100