Add the following code under the dataError method:


Private Sub grdProcess_DataError(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles grdProcess.DataError
If e.Exception IsNot Nothing AndAlso _
e.Context = DataGridViewDataErrorContexts.Commit Then

MessageBox.Show("Office_rec_ref value must be unique.")

End If
End Sub