flying linus
Registered User.
- Local time
- Yesterday, 19:25
- Joined
- Oct 1, 2004
- Messages
- 33
I have two tables, tblProducts and tblShopping_List.
Each table is configured as described below:
tblProducts:
ProductID - Primary Key (Autonumber)
ProductName (Text)
CategoryID (Number) - Linked to tblCategory
tblShopping_List:
ShoppingListID - Primary Key (Autonumber)
ProductID (Number) - Linked to tblProducts
Quantity (Number)
On a form, I am showing a list box of tblProducts items and a continuous subform of the tblShopping_List items. I want to create a command button that will take the ProductID of the selected item in the tblProducts and add that ProductID as new record in the tblShopping_List. But, I want the code to cycle through the items in the Shopping_List and if the item exists, then only update the quantity by one. If the item does not exist, then add a new record with the new ProductID.
Using code found here in one of the sample databases, I am able to add items to shopping list, but I can't seem to get it to update the quantity for existing items, it just adds a new record. Anyone have any sample code that can help me out?
Each table is configured as described below:
tblProducts:
ProductID - Primary Key (Autonumber)
ProductName (Text)
CategoryID (Number) - Linked to tblCategory
tblShopping_List:
ShoppingListID - Primary Key (Autonumber)
ProductID (Number) - Linked to tblProducts
Quantity (Number)
On a form, I am showing a list box of tblProducts items and a continuous subform of the tblShopping_List items. I want to create a command button that will take the ProductID of the selected item in the tblProducts and add that ProductID as new record in the tblShopping_List. But, I want the code to cycle through the items in the Shopping_List and if the item exists, then only update the quantity by one. If the item does not exist, then add a new record with the new ProductID.
Using code found here in one of the sample databases, I am able to add items to shopping list, but I can't seem to get it to update the quantity for existing items, it just adds a new record. Anyone have any sample code that can help me out?