I am using excel Userform and MS Server.
I have a Userform (OrderFrm) that I populate 2 multi column combo boxes with lists from my database (Customers & Items) there is also text box for inputting quantity and a text box that is populated with Price on a change event of the Items combo box. I have a textbox to input quantity and a change event on quantity textbox to calculate Item Total textbox.
I hav a Sub “AddItem” that adds the combo boxes and textboxes values to a “Order” Listbox on the Userform. The columns of the listbox are OrderId, CustomerId, ItemId, ItemName, Quantity, Price, ItemTotal. I have worked out getting the CustomerId and ItemId from the multi column comboboxes to the Order listbox along with ItemName, Quantity, Price and ItemTotal. At this point I have not Inserted into the Database yet.
In the Database I have 2 tables (tblOrder, tblOrderItem) that I want to insert the data from the Order listbox. The database is a relational db. The fields in the tblOrder are OrderId, CustomerId, OrderTotal. The fields in the tblOrderItem are OrderId, ItemId, Quantity, ItemTotal.
My hangup is at this point….
I have not inserted the items from the Order listbox to the 2 tables in db and Do NOT have a OrderId yet…so each line of the Order listbox is missing the OrderId which needs to come from the tblOrder table (auto increments) . I’m not sure how to sort this out, getting 1 Unique OrderId to use with every line of the Order listbox (because they all belong to 1 Order) so I can insert the records to the db tables.
The result I’m trying to get is the tblOrder gets 1 record inserted with OrderId (generated by db automatic) CustomerId and OrderTotal. TblOrderItem gets multiple records inserted from the Order listbox with a Unique OrderId for the inserted Items
I hope I have explained this clearly.
I have all the connection to the db sorted out already.
If I am approaching this inefficiently by using the Order listbox for staging the items before inserting to the db, alternative suggestions would be great.
Any assistance would be greatly appreciated.
I have a Userform (OrderFrm) that I populate 2 multi column combo boxes with lists from my database (Customers & Items) there is also text box for inputting quantity and a text box that is populated with Price on a change event of the Items combo box. I have a textbox to input quantity and a change event on quantity textbox to calculate Item Total textbox.
I hav a Sub “AddItem” that adds the combo boxes and textboxes values to a “Order” Listbox on the Userform. The columns of the listbox are OrderId, CustomerId, ItemId, ItemName, Quantity, Price, ItemTotal. I have worked out getting the CustomerId and ItemId from the multi column comboboxes to the Order listbox along with ItemName, Quantity, Price and ItemTotal. At this point I have not Inserted into the Database yet.
In the Database I have 2 tables (tblOrder, tblOrderItem) that I want to insert the data from the Order listbox. The database is a relational db. The fields in the tblOrder are OrderId, CustomerId, OrderTotal. The fields in the tblOrderItem are OrderId, ItemId, Quantity, ItemTotal.
My hangup is at this point….
I have not inserted the items from the Order listbox to the 2 tables in db and Do NOT have a OrderId yet…so each line of the Order listbox is missing the OrderId which needs to come from the tblOrder table (auto increments) . I’m not sure how to sort this out, getting 1 Unique OrderId to use with every line of the Order listbox (because they all belong to 1 Order) so I can insert the records to the db tables.
The result I’m trying to get is the tblOrder gets 1 record inserted with OrderId (generated by db automatic) CustomerId and OrderTotal. TblOrderItem gets multiple records inserted from the Order listbox with a Unique OrderId for the inserted Items
I hope I have explained this clearly.
I have all the connection to the db sorted out already.
If I am approaching this inefficiently by using the Order listbox for staging the items before inserting to the db, alternative suggestions would be great.
Any assistance would be greatly appreciated.