What is the best way to store selected items for later processing

Posted on 2003-02-25
Medium Priority
Last Modified: 2010-05-01
First let me explain how will I award points. I do not want any code but just the concept. I will award the points to that expert whos reasons convinse me. It may me wrong for others. I will look at 3-5 different ways of doing it.

Here is what I want to do.
I start my applicaton and a combo box is filled with item list from item table from MSAccess database.

I let user select the items from the combo box may be upto ten items.

I want to produce a Invoice/receipt which will list those items with the prices and once sale is completed i will update the respective tables.

Questions starts here?
What concept do I use to store the selected items? and do the rest of the processing?

Question by:dhamijap
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +3

Expert Comment

ID: 8020297
I think it depends on where the program will be residing. If it's local to your network then you may not need anything more than a sequential file or a random access file. If you are looking at something on a larger scale like a WAN, I'd recommend using a table in your access database.

You can use the ADODB reference and SQL statements to create a temporary table. For the name of the table just concatinate "temp" with a random number. You can use the randomnumber generator in VB to make a random number, say between 1 and 1 million. You'll want to store the name of that temp table so that when you're all done with that customer, you can go back and delete that temp table. The reason you'll want the random number generator for the name of the temp table is incase you have a whole bunch of people using this program at the same time.

I guess it really depends on where your program is being stored, how many people will be using it, what kind of security you need, etc

Author Comment

ID: 8020441
It is small application which will run on a stand alone desktop. Only one person will use.


Author Comment

ID: 8020463
So r u saying that i should create a temporary table in the memory? and process it any way I need. Please tell me why it is best over array?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 8021116
so you want the user to be able to select from list of items in a combobox that populates itself with data from a Access table.  When an item is selected it should be added to a list.  When the person is done selecting items they will click something to purchace those items (create an invoice)?

If you are not saving the info about the items that the person selected past the creation of the invoice then you will only need one table which should hold the item info like this

ID     Name     Description     Price
1      Widget   Something       1.23
2      Thingy   Something       5.43
3      Wobler   Something       3.45
4      Zinger   Something       0.98
5      Zapper   Something       7.24

Populate the combobox with the item names and have a 'Purchace' buttons next to it.
When the purchace button is clicked add the item info to a listbox below it based on the RecordSet used to populate the combobox.
Place a 'Check Out' button below the list box and when that it clicked show a Invoice form that will display the list of selected items and total.
Put 'Print' and 'Finish' buttons on the Invoice form.  When the Finish button is clicked the Invoice form should be closed and the original form should be cleared.

Hope this is what you were looking for....

Expert Comment

ID: 8021822
First of all, since you can't select multiple items in a combobox, I'm assuming that you either mean a listbox or as DaWeasel said, a combobox that populates a listbox.  (or is the user really going to select items one at a time from a combobox and on each selection, you populate whatever you decide to use per the whole point of this question?).

This seems to be to be WAY simpler than it must be.  If you're just giving your user a form with a list box on it and they're selecting multiple items in that listbox AND assuming you're doing the "purchase this" button on that form as well, you don't need to store the values anywhere.  They're in the listbox already.

For Each varItem in myListBox.ItemsSelected
     'Do whatever

That's it.

Perhaps you'd better give a little more detail about the scope of the process and the timing of selecting items versus generating your invoice.  Then we may be able to give you more complete answers.  Otherwise, it sounds like a simple form with simple controls and little code behind it...nothing more.

Hope this helps,

Author Comment

ID: 8025195
Da_Weasel &  tgraffham:

Since it is getting more involved than i wanted it to. I am raising points to 100.

You both have somewhat close to the answer. I have a datacombo automatically filled from a Access database table. Datacombo has ItemId as BoundColumn and Description as ListField. The user will select one item at a time e.g. User will search the item in the combo and click on "ADD" button to add to invoice. Actualy, I want to display all the selected items in a seperate frame with whatever control you will suggest. This control shoul be able to let me code for select and remove items. My question is how do i do that? which contorl do I use to create a listing of selected items(possible display the same control as invoice) and create a total sale amount? Once used pays for it(by clicking CompleteSale) I will take the listing ItemID and Quantity and update the ItemTable and also update the InvoiceDetail table.  I do not need any code to do any of this. I will post another question for code questions. I will code for whatever I  know how to insert data into the InvoiceDetail table, and then clear the control. It does not have to be control I want some one who knows how to do it best.

* I have thought of keeping the items in Array or Recordset etc. But there might be something better than what i can think. Please help. I do not want this question drag for long. Thanks for reading all that.

This is how I expect the answer:
1 Use "????" controls
2 use "XXX" control to hold the data
3 use "this" control to display the invoice
4 couple lines to tell me why?
1 Do this way
2 couple lines to tell me why?

Of course, you can type as much as you want to make your point. I am just trying to save you guys time. It is upto you. Thanks again.

Expert Comment

ID: 8025551
Can they order more than of single item?

Expert Comment

ID: 8026956


Author Comment

ID: 8027060
yes, as many as they want or we can limit to 10

Expert Comment

ID: 8027184
this is a web app yes ?

Author Comment

ID: 8027264
no stand alone on a desktop using windows XP home.

Accepted Solution

Da_Weasel earned 400 total points
ID: 8027353
ok so this is the simplest method to get what you want.

make array STRUCT that is the same size as the number of items in the combo with the following members

eachtime they click on add item you use the ID value to to find the same item in the array and increment its item count
then update the listbox with the contents of the array, so the list box shows selected items like this
(2) Widget
(1) Wooble
(10) Thingies

when the Check Out button is clicked you can use the Array.Count and Rs to calculate the prices
I would use a Crytstal Report control.

Author Comment

ID: 8027680
Da Weasel:

Just want to see what you are saying:
Suppose I have 50 records in the table.
Now DataCombo has 50 items

Create a Array with 50 length to store my data to do plus or minus of items sold or returned.

populate a listbox with the user selected items.

User crystal report control to produce invoice or bill\receipt.

Is crystal report control a part of VB6?

Expert Comment

ID: 8265985
Force Accepted (http://www.experts-exchange.com/Community_Support/CleanUp/Q_20565385.html)

Community Support Moderator @Experts Exchange

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question