0

hey guys, can you help me? im using a datagridview, and it is connected to ms access. every time i have an input same in the column where primary key is I already got an error. can you guys how to show a messagebox if the Customer Contact number is already in use? here is my code.

Dim amount As Integer
amount = Remaining_bo_es_TextBox.Text - txtOrder.Text
Remaining_bo_es_TextBox.Text = amount
Label5.Text = txtOrder.Text * PriceTextBox1.Text
Label1.Text = Product_NameLabel1.Text
Transactions.TblTransactionsTableAdapter.Insert(Me.txtCustName.Text, Me.txtCustNumber.Text, Me.txtCustEmAdd.Text, Me.Label1.Text, Me.Label5.Text, Today.Date.ToShortDateString)
Transactions.TableAdapterManager.UpdateAll(Transactions.DanlexTransactionsDataSet)
Me.Validate()
Me.TblProductInfoBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Db1DataSet)
Me.TblProductInfoTableAdapter.Fill(Me.Db1DataSet.tblProductInfo)
Label4.Text = "click new transaction"

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by AndreRet
0

You will have to check before your INSERT statement if the record exist. This can be done by using the BOF or EOF functions. If any of these are true, the record does not exist and you can add the data, else exit the sub.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.