Hi all

i have this bit of code for searching for a number from a db and returning it to a datagridview

vb.net Code:
  1. Dim con5 As New OleDb.OleDbConnection
  2.         Dim ds5 As New DataSet
  3.         Dim da5 As OleDb.OleDbDataAdapter
  4.         Dim SQL5 As String
  5.         con5.ConnectionString = My.Settings.GoodsinConnect
  6.         con5.Open()
  7.         ds5.Clear()
  8.         SQL5 = "SELECT * FROM [ReceiptLines] WHERE [PartNo] ='" & Partnumber & "'"
  9.         da5 = New OleDb.OleDbDataAdapter(SQL5, con5)
  10.         da5.Fill(ds5, "ReceiptLines")
  11.         dgvPartNumbers.DataSource = ds5.Tables(0).DefaultView
  12.         con5.Close()

This works fine.

However when a user updates a record that is shown via another form. When they are returned back to the main form i want the record to be updated.

So for now i put a simple timer in that looks when the record is updated and a value is changed and when it has then it triggers

vb.net Code:
  1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  2.         If RefreshData = 1 Then
  3.              btnSearch_Click(Me, EventArgs.Empty)
  4.             RefreshData = 0
  5.         End If
  6.     End Sub

I've also tried:

vb.net Code:
  1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  2.         If RefreshData = 1 Then
  3.              btnSearch.PerformClick()
  4.             RefreshData = 0
  5.         End If
  6.     End Sub


Although it goes through the code like it would it doesnt actually update the datagridview.

However if i press the button on the form it updates it.


Can anyone help me out here.

Thanks
Alex