Question Adding Multiple Rows for the same CustomerID

maneeshmassey

New member
Joined
Sep 8, 2011
Messages
2
Programming Experience
Beginner
I have a simple application for taking Customer orders and their Products. I am using Visual Studio 2008 Express Edition and MS Access 2007.My application uses multiple forms. One of the forms is an Add form from where a New Customer along with his/her details like address, phone, city, state etc can be added. Another form is for the Product Details to be added.I want to know how to add Multiple Product Details for the same CustomerID, as a Customer can order multiple products. I am using the following code for the Add button:
Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click

MyBindingSource.EndEdit()
DialogResult = Windows.Forms.DialogResult.OK End Sub


This adds a new Customer into the Database with an AutoIncremented CustomerID.
Now I need to know how to add 2 or more Product Details for this same CustomerID. How can I do this ? Can anyone please help ?
 
You should put all the data into a single DataSet with related tables. Follow this link to learn how to get the auto-generated ID from the parent table and push it to the child table(s) as you save the whole lot:

Retrieve Access AutoNumber Value After Insert
 
As luck would have it, Microsoft have published a tutorial on EXACTLY what youre trying to do (it's the parent/child example of customers/orders rather than customers/products but i think you'll be fine)

Click the DW3 link in my signature then click the Creating a Simple Data App link
 
Back
Top