Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB6 ListView MS-Access
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()
SQL = "SELECT * FROM [NOTE]"
.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
 
SQL = "INSERT INTO [NOTE](DOC_NO,DOC_SUBNO,AID,QTY,RATE,TOTAL_AMNT,DOC_TYPE,DOC_DATE,REMARK,LOC_ID,SUP_ID) " & _
" 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)
Next
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 22:58pm
surkhi623
Edited 6-May-13 22:48pm
CPallini325.7K
v4

1 solution

Rate this: bad
good
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
      Permalink  
    Comments
    cool_sari at 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 at 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)



    Advertise | Privacy | Mobile
    Web03 | 2.8.1411022.1 | Last Updated 7 May 2013
    Copyright © CodeProject, 1999-2014
    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