Hi,
I wanne add a new record to a access 2007 database with vb.net 2010. I've tried various methods, but cannot get this to work correct.
my Last code is: "Private Sub cmdAccept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAccept.Click
'On Error Resume Next
PanelHide.Visible = True
Dim Lopw
Dim con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & CurDir() & "\SM.accdb;")
con.Open()
For Lopw = 1 To (LstBarcode.Items.Count - 1)
Dim NewJobCardRow As DataRow = SMDataSet7.Tables("JobCard").NewRow()
NewJobCardRow("JobNumber") = txtJobNo.Text
NewJobCardRow("JobDescription") = TextBox2.Text
NewJobCardRow("CustomerBarCode") = TextBox3.Text
NewJobCardRow("ItemBarCode") = LstBarcode.Items(Lopw).ToString
NewJobCardRow("ItemDiscription") = LstDescript.Items(Lopw).ToString
NewJobCardRow("ItemPrice") = Val(LstCost.Items(Lopw).ToString)
NewJobCardRow("ItemVat") = (Val(LstCost.Items(Lopw).ToString) - (Val(LstCost.Items(Lopw).ToString) * 14 / 100))
NewJobCardRow("ItemDiscount") = 0
NewJobCardRow("item1") = "Waiting GO"
NewJobCardRow("item2") = TextBox3.Text
NewJobCardRow("Item3") = ""
NewJobCardRow("Item4") = txtMoreInfo.Text
NewJobCardRow("Item5") = ""
NewJobCardRow("Item6") = 0
NewJobCardRow("item7") = 0
NewJobCardRow("item8") = Now
NewJobCardRow("Item9") = 0
NewJobCardRow("Item10") = 0
SMDataSet7.Tables("JobCard").Rows.Add(NewJobCardRow)
Try
JobCardTableAdapter.Update(SMDataSet7.Tables("JobCard"))
Catch x As Exception
End Try
If LstBarcode.Items.Count = Lopw Then Exit For
Next
cmdClose.Enabled = True
cmdNew.Enabled = True
End Sub"

this code ONLY OVERWRITES THE 1st record in the table. and does not add any new records, and does not loop through the for next statement correctly.
I set up the for next statement, because there might be more than 1 scanned items, the job number, JobDescription etc stays the same, LstBarcode.Items(Lopw).ToString, Val(LstCost.Items(Lopw).ToString), etc is the items that is scanned - I put these in a list control. Each list item is a new scanned item.

Hope someone might be able to help