title: Refresh a datagrid in another form
body: <p>I am using VB to make something to change records in a database. I have a table called tblCustomers. When the user clicks a button on the homeForm, a new form called FormNewCustomer appears which has text boxes for the user to input info to put in the database. After submitting it, the data does get inserted, but it doesn't show in the datagridview. </p>
  
  <p>This is my code:</p>
  
  <pre><code>Imports System.Data.OleDb
  Public Class FormNewCustomer
      Public connstring As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=ProgramDatabase.accdb"
      Public conn As New OleDbConnection(connstring)
      Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
          Me.Close()
      End Sub
  
      Private Sub btnCopy_Click(sender As Object, e As EventArgs) Handles btnCopy.Click
          If txtCustomerName.Text = "" Or txtAC.Text = "" Then
              MsgBox("Enter a Customer Name and a Customer Reference.")
          Else
              conn.Open()
              Dim SqlQuery As String = "INSERT INTO tblCustomers (CustomerName,AC,Address,Phone,Email) VALUES (@CustomerName,@AC,@Address,@Phone,@Email)"
              Dim SqlCommand As New OleDbCommand
              With SqlCommand
                  .CommandText = SqlQuery
                  .Parameters.AddWithValue("@CustomerName", txtCustomerName.Text)
                  .Parameters.AddWithValue("@AC", txtAC.Text)
                  .Parameters.AddWithValue("@Address", txtAddress.Text)
                  .Parameters.AddWithValue("@Phone", txtPhone.Text)
                  .Parameters.AddWithValue("@Email", txtEmail.Text)
  
                  .Connection = conn
                  .ExecuteNonQuery()
              End With
              conn.Close()
              MsgBox("Successfully added new Customer.")
              FormHome.DataGridView1.Refresh()
              Me.Close()
  
          End If
      End Sub
  End Class
  </code></pre>