Hi All,

I am trying to update my form once the delete button is clicked. There are several fields like Name, Date, Date of Birth and so on. Once I delete a record I want the form to automatically load with new / updated data. This form fetches data from MS Access using OLEDB
Once when I close the application and reopen then form will be updated with new values. But I want this to happen once the form loads after deleting.
I have spent a long long time trying this but did not get any solution.
Please help

Regards,
Ashwin

Here is the code

 s.Clear()
        ds1.Clear()
        ds2.Clear()
        ds.GetChanges()
        ds1.GetChanges()
        ds2.GetChanges()
        Application.DoEvents()
        select_User = temp1
        Button2.Enabled = True
        Button12.Enabled = True
        Button3.Enabled = True
        Button13.Enabled = True
 Application.DoEvents()

        System.Threading.Thread.Sleep(3000)

        If order = 1 Then
            cmd1 = New OleDb.OleDbCommand("SELECT * FROM Query_LeadDashboard WHERE Advisor_ID = " & select_User & " ORDER BY Lead_DateTime", con)
            sql = "SELECT * FROM Query_LeadDashboard WHERE Advisor_ID = " & select_User & " ORDER BY Lead_DateTime"
        ElseIf order = 2 Then
            cmd1 = New OleDb.OleDbCommand("SELECT * FROM Query_LeadDashboard WHERE Advisor_ID = " & select_User & " ORDER BY Lead_NextContactTime", con)
            sql = "SELECT * FROM Query_LeadDashboard WHERE Advisor_ID = " & select_User & " ORDER BY Lead_NextContactTime"
        Else
            cmd1 = New OleDb.OleDbCommand("SELECT * FROM Query_LeadDashboard WHERE Advisor_ID = " & select_User & " ORDER BY Lead_ID", con)
            sql = "SELECT * FROM Query_LeadDashboard WHERE Advisor_ID = " & select_User & " ORDER BY Lead_ID"
        End If
        Dim sdr1 As OleDb.OleDbDataReader = cmd1.ExecuteReader()
        inc = -1
        sql2 = "SELECT Outcome_Name FROM Query_CallsHistory WHERE Advisor_ID = " & select_User
        sql3 = "SELECT DISTINCT Lead_ID FROM Query_LeadDashboard WHERE Advisor_ID =" & select_User
        da3 = New OleDb.OleDbDataAdapter(sql3, con)
        da3.Fill(ds2, "Query_LeadDashboard")
        da = New OleDb.OleDbDataAdapter(sql, con)
        da.Fill(ds, "Query_LeadDashboard")
        da2 = New OleDb.OleDbDataAdapter(sql2, con)
        da2.Fill(ds1, "Query_CallsHistory")
        rc = ds2.Tables("Query_LeadDashboard").Rows.Count
............
...........
........
  Label56.Text = ds.Tables("Query_LeadDashboard").Rows(0).Item(0).ToString
            Label57.Text = ds.Tables("Query_LeadDashboard").Rows(0).Item(15)
            TextBox1.Text = ds.Tables("Query_LeadDashboard").Rows(0).Item(13).ToString
            TextBox4.Text = ds.Tables("Query_LeadDashboard").Rows(0).Item(14).ToString
            TextBox2.Text = ds.Tables("Query_LeadDashboard").Rows(0).Item(1).ToString
            TextBox3.Text = ds.Tables("Query_LeadDashboard").Rows(0).Item(2).ToString
            Label50.Text = ds.Tables("Query_LeadDashboard").Rows(0).Item(11).ToString
            Label53.Text = ds.Tables("Query_LeadDashboard").Rows(0).Item(5).ToString
            Label70.Text = ds.Tables("Query_LeadDashboard").Rows(0).Item(16).ToString
            Label74.Text = ds.Tables("Query_LeadDashboard").Rows(0).Item(17).ToString
            Label77.Text = ds.Tables("Query_LeadDashboard").Rows(0).Item(18).ToString
            Label80.Text = ds.Tables("Query_LeadDashboard").Rows(0).Item(19).ToString
            DateTimePicker1.Value = ds.Tables("Query_LeadDashboard").Rows(0).Item(3)
.........
..........

What you need to do is clear your dataset and refill it using your adapter, this will insure that the new/changed records/info are displayed rather than the original records/info.

'dbAdapter is my adapter
'dbDataset is my dataset
'dbTable is my table object
'dbConnect is my Database Connection

Dim sql As String = "SELECT * FROM Your_Table"

dbAdapter = New OleDb.OleDbDataAdapter(sql, dbConnect.ConnectionString)
dbDataset.Clear()
dbAdapter.Fill(dbDataset, "Your_Table")
dbTable = dbDataset.Tables("Your_Table")

After this code you just set your textbox values again, and it will be the new data.

Hope this helps

Please reply if you have more ????