(DESKTOP)Start New Order

Ok I’m complete stuck in a paradox i feel like cause what I’m trying to do i can’t wrap my head around it. i need the user to be able to create a new order and it get the last number used in my PK ID and add 1 to it and display that number in a label the user knows a new invoice is started. after that i need it to write all the info from all my fields to an xls file and to my database via a button Name (Add to Order) when that is click it adds all the info from the fields to the xls spreadsheet and erases all the info in all fields so they can add another item to the xls spreadsheet. but how can i get it to write to the invoice database just once so it doesn’t create multiple invoice because the user has more than one item to add ? just completely lost. if anyone can help me out with an small example and doesn’t just point me to Eddies electronics cause none of that is what i need. been in and out of that program so please if you use that as a reference then please explain what your doing with it. So a quick look at what I’m doing:

  1. User needs to be able to Click button to Start new Order and read last PK ID and add 1 to it and display number in Label.text

  2. User needs to be able to Add multiple items to XLS sheet without creating multiple Invoices in the database

  3. User needs to be able to submit the order and name it the xls the same as the ID that was just submitted in the invoice database.

Just lost to all hell . i can connect to my database and read and write to it just not sure how to do all this at once.

PS. Visual Learner.

Thank you
Travis McBride

You’re making this really hard for yourself. Not sure if it’s because of your requirements or if you just haven’t thought this through clearly. I would recommend that you save everything in the database (hint: you need a line items table) and write the XLS out all at once when the user is done adding lines. At any given time, you have 2 records in hand: the order header and the current line item. Commit the header to the database when the user adds the first line item, and at that point retrieve both a unique record number (to use as the foreign key in the line items) and the next highest invoice number. The invoice number should not be used as a foreign key.

@Tim Hare I think I’m just making it hard on myself . Im an old VB programmer and moved to this just about 3 weeks ago and i haven’t had to do any programming in years! so yeah its hard for me to remember all the syntax that I’m going to have to use or how to actually use it properly. Can you show me a little example of how that would play out. Im understanding exactly what your saying I need to do just not sure how to start it. I understand i need to Keep 2 records The New item the User is making and the Items in the Cart. Anyway you can show me what you mean.?

Thank you
Travis McBride