Hello,
Ive got a form with bound txt boxes that displays the information in the database. Now ive put an edit button which when its clicked it allow the txt boxes and combo boxes to be edited.
Ive got the edits and so forth to work.
This is the coding for my Save Button
Code:
Private Sub btnSave_Click()
If Trim("" & Description.Value) = "" Then
MsgBox "Please enter a Description", vbExclamation, "Cannot Save"
ElseIf Trim("" & Category.Value) = "" Then
MsgBox "Please select a Category", vbExclamation, "Cannot Save"
ElseIf Trim("" & Quantity.Value) = "" Then
MsgBox "Please enter a Quantity", vbExclamation, "Cannot Save"
ElseIf Not IsNumeric(Quantity.Value) Then
MsgBox "Quantity can only contain numbers", vbExclamation, "Cannot Save"
ElseIf Quantity.Value = 0 Then
MsgBox "The quantity must be over Zero", vbExclamation, "Cannot Save"
ElseIf Quantity.Value < 0 Then
MsgBox "The quantity must be over Zero", vbExclamation, "Cannot Save"
ElseIf Price.Value = 0 Then
MsgBox "The price must be over Zero", vbExclamation, "Cannot Save"
ElseIf Price.Value < 0 Then
MsgBox "The price must be over Zero", vbExclamation, "Cannot Save"
ElseIf Trim("" & Price.Value) = "" Then
MsgBox "Please enter a Price", vbExclamation, "Cannot Save"
ElseIf MsgBox("Edit Product Details?", vbOKCancel + vbQuestion, "Confirmation") = vbOK Then
'get a reference to the record set in the main form
Set dbs = CurrentDb
Set editprod = dbs.OpenRecordset("tblProduct")
editprod.Edit
editprod("[Description]") = Description.Value
editprod("[Category]") = Category.Value
editprod("[Size]") = Size.Value
editprod("[Quantity]") = Quantity.Value
editprod("[Price]") = "£" + Price.Value
editprod.Update
MsgBox ("Updated")
End If
Exit Sub
End Sub
Now that code does add to the product table but it dont change that specific Record. It just overwrites the information in the 1st Record.
And if i edit another record, the 1st Record in the database gets overwritten again.
Any ideas how i can stop this and change the values of the product i have chosen?
Each product does have a Uniwue ProductID but i cant get it to change the Record that is chosen.
All help is welcome..
Thanks..