i want when user clicks on save button I want to update the database and refresh the listview on the curren page.
i have written a code but data is not instantly comming after save button .Here is the code what i have written.I simple Want when Press ok .addded record should go in a listview.but is not refreshing.

Private Sub Command2_Click()
        If (CheckInput) = True Then
        End If
        y = MsgBox("do you add this record", vbYesNo + vbQuestion, "message")
        If y = vbYes Then
        Set con = New ADODB.Connection
        Dim success As Boolean
        success = OpenConnection(con)
        If success = False Then
           MsgBox ("Cannot open Connection")
         End If
        Set rs = New ADODB.Recordset
        rs.Open "Select * from supplierS", con, adOpenDynamic, adLockOptimistic
        rs.AddNew
'       rs.Fields("item_type") = Combo1.Text
        rs.Fields("id") = Val(Text1.Text)
        rs.Fields("Supplier_name") = Text2.Text
        rs.Fields("Contact_person") = Text3.Text
        rs.Fields("contact_no") = Text4.Text
        rs.Fields("office_address") = Text5.Text
        rs.Fields("emails") = Text6.Text
        rs.Fields("website") = Text7.Text
        rs.Fields("fax_no") = Text8.Text
        rs.Update
        rs.Close
        Set rs = Nothing
        con.Close
        Set con = Nothing
        Me.Refresh
        MsgBox ("Data Saved")
        Supplier_master.Refresh
        Combo1.Text = ""
        Text1.Text = ""
        Text2.Text = ""
        Text3.Text = ""
        Text4.Text = ""
        Text5.Text = ""
        Text6.Text = ""
        Text7.Text = ""
        Text8.Text = ""
'       con.BeginTrans
'       SQL = "INSERT INTO Supplier(item_type,Supplier_id,Supplier_name,Contact_person,Contact_no,Office_address,emails,website,Fax_no) values('" & Combo1.Text & "','" & Text1.Text & "','" & Text2.Text & " ','" & Text4.Text & "','" & Text3.Text & "','" & Text5.Text & "','" & Text6.Text & "','" & Text7.Text & "','" & Text8.Text & "')"
'       con.Execute (SQL)
'       MsgBox SQL
'       con.CommitTrans
'       MsgBox (Combo1.Text)
        End If
        End Sub

After the insert operation you need to call the REQUERY method of the recordset before passing the same to the displaying control.

can you tell me how should i pass requery metohod if you don't mind.here is the code of insert .since i am trying from some days
still not able to refresh information on a listview.

Private Sub Command2_Click()
        If (CheckInput) = True Then
        End If
        y = MsgBox("do you add this record", vbYesNo + vbQuestion, "message")
        If y = vbYes Then
        Set con = New ADODB.Connection
        Dim success As Boolean
        success = OpenConnection(con)
        If success = False Then
           MsgBox ("Cannot open Connection")
           Exit Sub
         End If
        Set rs = New ADODB.Recordset
        rs.Open "Select * from supplierS", con, adOpenDynamic, adLockOptimistic
        rs.AddNew
'       rs.Fields("item_type") = Combo1.Text
        rs.Fields("id") = Val(Text1.Text)
        rs.Fields("Supplier_name") = Text2.Text
        rs.Fields("Contact_person") = Text3.Text
        rs.Fields("contact_no") = Text4.Text
        rs.Fields("office_address") = Text5.Text
        rs.Fields("emails") = Text6.Text
        rs.Fields("website") = Text7.Text
        rs.Fields("fax_no") = Text8.Text
        rs.Update
        rs.Close
        Set rs = Nothing
        con.Close
        Set con = Nothing
        Me.Refresh
        MsgBox ("Data Saved")
        Supplier_master.Refresh
        Combo1.Text = ""
        Text1.Text = ""
        Text2.Text = ""
        Text3.Text = ""
        Text4.Text = ""
        Text5.Text = ""
        Text6.Text = ""
        Text7.Text = ""
        Text8.Text = ""
        End If
        End Sub

if you are using ADO. Use the refresh method of the recordset object. and then pass the same to the listview.

how should i pass the same .can you tell me please debasis.
i am waiting for your reply.Here is the code what i have written.

Private Sub Command2_Click()
        If (CheckInput) = True Then
        End If
        y = MsgBox("do you add this record", vbYesNo + vbQuestion, "message")
        If y = vbYes Then
        Set con = New ADODB.Connection
        Dim success As Boolean
        success = OpenConnection(con)
        If success = False Then
           MsgBox ("Cannot open Connection")
           Exit Sub
         End If
        Set rs = New ADODB.Recordset
        rs.Open "Select * from supplierS", con, adOpenDynamic, adLockOptimistic
        rs.AddNew
'       rs.Fields("item_type") = Combo1.Text
        rs.Fields("id") = Val(Text1.Text)
        rs.Fields("Supplier_name") = Text2.Text
        rs.Fields("Contact_person") = Text3.Text
        rs.Fields("contact_no") = Text4.Text
        rs.Fields("office_address") = Text5.Text
        rs.Fields("emails") = Text6.Text
        rs.Fields("website") = Text7.Text
        rs.Fields("fax_no") = Text8.Text
        rs.Update
'        rs.Close
    [B]    Dim suppliername, id, contact_person, contact_no, office_address, emails, website, fax_no As String  'again calling database fields
        suppliername = IIf(IsNull(rs!supplier_name), "", rs!supplier_name)
        id = IIf(IsNull(rs!id), "", rs!id)
        contact_person = IIf(IsNull(rs!contact_person), "", rs!contact_person)
        contact_no = IIf(IsNull(rs!contact_no), "", rs!contact_no)
        office_address = IIf(IsNull(rs!office_address), "", rs!office_address)
        emails = IIf(IsNull(rs!emails), "", rs!emails)
        website = IIf(IsNull(rs!website), "", rs!website)
        fax_no = IIf(IsNull(rs!fax_no), "", rs!fax_no)
        Supplier_master.ListView1.Refresh[/B]        Set rs = Nothing
        con.Close
        Set con = Nothing
        Me.Refresh
        MsgBox ("Data Saved")
        Combo1.Text = ""
        Text1.Text = ""
        Text2.Text = ""
        Text3.Text = ""
        Text4.Text = ""
        Text5.Text = ""
        Text6.Text = ""
        Text7.Text = ""
        Text8.Text = ""
        End If
        End Sub
This article has been dead for over six months. Start a new discussion instead.