Hi…![]()
I need help to highlight the value in DGV cell after updating these values from Search form so that the user knows the row which been updated…
Codes in search form
Code:Imports System.Data Imports System.Data.OleDb Public Class Form2 Dim frm As New Form1 Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source =" & Application.StartupPath & "\data.mdb" Dim Conn As New OleDbConnection(ConStr) Dim DataSet1 As New DataSet Dim SQLstr As String Dim m As String Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click DataSet1 = New DataSet Static m As Integer = 0 If tbSearch.Text = Trim("") Then Exit Sub ExactSearch() Conn.Open() Dim DataAdapter1 As New OleDbDataAdapter(SQLstr, Conn) DataAdapter1.Fill(DataSet1, "store") Conn.Close() tbSearchResulItemPartNumber.DataBindings.Clear() tbSearchResultItemDeascriptions.DataBindings.Clear() tbSearchResultItemLocation.DataBindings.Clear() tbItemQuantitySearchResult.DataBindings.Clear() tbSearchResulItemPartNumber.DataBindings.Add("Text", DataSet1, "store.Item Part Number") tbSearchResultItemDeascriptions.DataBindings.Add("Text", DataSet1, "store.Item Descriptions") tbSearchResultItemLocation.DataBindings.Add("Text", DataSet1, "store.Item Location") tbItemQuantitySearchResult.DataBindings.Add("Text", DataSet1, "store.Item Quantity") DataGridView1.DataSource = DataSet1 DataGridView1.DataMember = "store" DataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells btnEDIT.Enabled = True btnSUBTRACT.Enabled = True btnADD.Enabled = True tbItemQuantityCalculation.Enabled = True If Me.BindingContext(DataSet1, "store").Count = 0 Then MsgBox("No Result??!! ") Form1.Show() Me.Close() End If Exit Sub End Sub Public Sub ExactSearch() SQLstr = "SELECT * FROM store WHERE [Item Part Number ]= '" & tbSearch.Text & "'" End Sub Private Sub btnBACK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBACK.Click Me.Close() Form1.Show() End Sub Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Conn.Open() Try Dim cmd As OleDbCommand = New OleDbCommand("Select [Item Part Number] from store", Me.Conn) Dim reader As OleDbDataReader = cmd.ExecuteReader() Dim list As New AutoCompleteStringCollection While reader.Read list.Add(reader.Item("Item Part Number")) End While tbSEARCH.AutoCompleteMode = AutoCompleteMode.SuggestAppend tbSEARCH.AutoCompleteSource = AutoCompleteSource.CustomSource tbSEARCH.AutoCompleteCustomSource = list Catch ex As Exception Conn.Close() Throw ex End Try Conn.Close() End Sub Private Sub btnSUBTRACT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSUBTRACT.Click Dim x As Integer If Not Integer.TryParse(Me.tbItemQuantityCalculation.Text, x) Then MessageBox.Show("Only Integer values Here") tbItemQuantityCalculation.SelectAll() tbItemQuantityCalculation.Focus() Exit Sub End If Dim strUPD As String strUPD = "Update store set" strUPD &= "[Item Quantity] = [Item Quantity] - " & x.ToString() strUPD &= " Where [Item Part Number] = '" & tbSearchResulItemPartNumber.Text & "'" Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source =" & Application.StartupPath & "\data.mdb" Dim Conn As New OleDbConnection(ConStr) Dim SavInto As New OleDb.OleDbCommand SavInto.Connection = Conn SavInto.CommandType = CommandType.Text SavInto.CommandText = strUPD Conn.Open() SavInto.ExecuteNonQuery() Conn.Close() MsgBox("Item Quantity Updated Successfully") Me.Close() Form3.Show() End Sub Private Sub btnADD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnADD.Click Dim x As Integer If Not Integer.TryParse(Me.tbItemQuantityCalculation.Text, x) Then MessageBox.Show("Only Integer values Here") tbItemQuantityCalculation.SelectAll() tbItemQuantityCalculation.Focus() Exit Sub End If Dim strUPD As String strUPD = "Update store set" strUPD &= "[Item Quantity] = [Item Quantity] + " & x.ToString() strUPD &= " Where [Item Part Number] = '" & tbSearchResulItemPartNumber.Text & "'" Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source =" & Application.StartupPath & "\data.mdb" Dim Conn As New OleDbConnection(ConStr) Dim SavInto As New OleDb.OleDbCommand SavInto.Connection = Conn SavInto.CommandType = CommandType.Text SavInto.CommandText = strUPD Conn.Open() SavInto.ExecuteNonQuery() Conn.Close() MsgBox("Item Quantity Updated Successfully") Me.Close() Form3.Show() End Sub Private Sub btnEDIT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEDIT.Click btnEDIT.Enabled = False btnSAVE.Enabled = True btnCANCEL.Enabled = True tbSearchResultItemDeascriptions.ReadOnly = False tbSearchResultItemDeascriptions.BackColor = Color.White tbSearchResultItemLocation.ReadOnly = False tbSearchResultItemLocation.BackColor = Color.White End Sub Private Sub btnCANCEL_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCANCEL.Click btnEDIT.Enabled = True btnSAVE.Enabled = False btnCANCEL.Enabled = False tbSearchResultItemDeascriptions.ReadOnly = True tbSearchResultItemDeascriptions.BackColor = Color.PowderBlue tbSearchResultItemLocation.ReadOnly = False tbSearchResultItemLocation.BackColor = Color.PowderBlue End Sub Private Sub btnSAVE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSAVE.Click Dim n As String = Me.tbSearchResulItemPartNumber.Text Dim SavInto As New OleDb.OleDbCommand Dim ConStr As String = _ "Provider=Microsoft.Jet.OLEDB.4.0; Data Source =" & _ Application.StartupPath & "\data.mdb" Dim Conn As New OleDbConnection(ConStr) SavInto.Connection = Conn SavInto.CommandType = CommandType.Text SavInto.CommandText = "UPDATE store SET [Item Descriptions] = '" & Trim(tbSearchResultItemDeascriptions.Text) & "' , [Item Location] = '" & Trim(tbSearchResultItemLocation.Text) & "' , [Item Part Number ]= '" & Trim(tbSearchResulItemPartNumber.Text) & "' WHERE [Item Part Number ] ='" & n & "'" Conn.Open() SavInto.ExecuteNonQuery() Conn.Close() MsgBox("Database Updated Successfully") Me.Close() Form3.Show() End Sub End Class
Codes in DataGridView form
Any ideas…Code:Public Class Form3 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Close() Form1.Show() End Sub Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'DataDataSet.STORE' table. You can move, or remove it, as needed. Me.STORETableAdapter.Fill(Me.DataDataSet.STORE) End Sub End Class![]()
Regards…![]()


Reply With Quote
