I tried your suggestion and it still did not work. I have a feeling where I have put the code is in the wrong place. In the database barcodeid is a text field. In access database it is a text field. I will paste the code that I have for that button. Thanks for your help again. Private Sub btnUpdateOSSF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdateOSSF.Click Dim changes As Integer Dim commandBuilder As New OleDb.OleDbCommandBuilder(dataadapter) Dim i As String Dim str As String Dim comm As New OleDbCommand OleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & Application.StartupPath & "\backup.mdb;" comm.Connection = OleDbConnection1 Me.BindingContext(dt).EndCurrentEdit() Dim strWrk As String = dt.Rows(0).Item("DateIN") = DateTimePicker1.Value Dim strWrk1 As String = dt.Rows(0).Item("TimeIN") = DateTimePicker2.Value changes = dataadapter.Update(dt) If changes > 0 Then MsgBox(changes & " changed rows were stored in the database.") Else MsgBox("No changes made.") End If Try OleDbConnection1.Open() 'Copy existing record from original table to history table. comm.CommandText = "INSERT INTO History (barcodeid, Dateout, timeout, location, comments) SELECT barcodeid, Dateout, timeout, location, comments FROM testbackup WHERE barcodeid='" & DgDisplay.Item(DgDisplay.CurrentRowIndex, 0).ToString & "'" comm.ExecuteNonQuery() 'Delete old history record. comm.CommandText = "DELETE FROM history WHERE (barcodeid = '" & DgDisplay.Item(DgDisplay.CurrentRowIndex, 0).ToString & "') AND (ID NOT IN (SELECT TOP 5 ID FROM history where barcodeid = '" & DgDisplay.Item(DgDisplay.CurrentRowIndex, 0).ToString & "' ORDER BY ID Desc))" comm.ExecuteNonQuery() comm.CommandText = "Update testbackup set datein = null, timein = null where barcodeid = ?" If DgDisplay.CurrentRowIndex < 0 Then comm.Parameters.Add("", DBNull.Value) Else comm.Parameters.Add("", DgDisplay.Item(DgDisplay.CurrentRowIndex, 0).ToString) End If comm.ExecuteNonQuery() Catch ex As Exception MsgBox(ex.Message) Err.Clear() Finally O