Hi.
I have a combobox that has list of food and a textbox to enter the amount. When select a food, then enter the amount, it will save in Access after clicked the add button. But if I do it again but different food, it will save below the 1st food.
I want to save it in the same row. Can it be done? This is my save/add code.
con.Open()
sql = "SELECT * FROM CakePie"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "CakePie")
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsnewrow As DataRow
dsnewrow = ds.Tables("CakePie").NewRow()
With CakeComboBox
If .Text = "Tiramisu Cake" Then
dsnewrow.Item("TiramisuCake") = QuantTextBox.Text
ElseIf .Text = "Red Velvet Cake" Then
dsnewrow.Item("RedVelvetCake") = QuantTextBox.Text
ElseIf .Text = "Vanilla French Cake" Then
dsnewrow.Item("VanillaFrenchCake") = QuantTextBox.Text
ElseIf .Text = "Key Lime Pie" Then
dsnewrow.Item("KeyLimePie") = QuantTextBox.Text
ElseIf .Text = "Pecan Pie" Then
dsnewrow.Item("PecanPie") = QuantTextBox.Text
ElseIf .Text = "Lemon Meringue Pie" Then
dsnewrow.Item("LemonMeringuePie") = QuantTextBox.Text
ElseIf .Text = "Extra Cheese Cheesecake" Then
dsnewrow.Item("ExtraCheeseCheesecake") = QuantTextBox.Text
ElseIf .Text = "All Berry Cake" Then
dsnewrow.Item("AllBerryCake") = QuantTextBox.Text
End If
End With
ds.Tables("CakePie").Rows.Add(dsnewrow)
da.Update(ds, "CakePie")
con.Close()
I tried with the "If" but it still save in the next row. I have no idea.