PDA

View Full Version : send contents of listbox to table



mpearce
07-06-2009, 08:53 AM
How can i send the contents of a listbox to a table??

OBP
07-06-2009, 09:04 AM
Mike, you can loop through the list box items and append them a suitable table using a VBA Recordset.

I haven't heard from you on your other Thread.

mpearce
07-07-2009, 12:57 PM
could you walk me throught that...i am not too familiar with recordsets

OBP
07-08-2009, 06:20 AM
What is the name of the Table and it's Field names

mpearce
07-08-2009, 12:51 PM
Table Name: ProjectOrder

Fields:
location
existQTY
efix
Ewatts
ekw
ekw_h
ProposedQTY
pfix
pwatts
hrs
pkW
pkW_h
skw
skw_h
saved

OBP
07-09-2009, 02:56 AM
So which Field contains the List box Items?

mpearce
07-09-2009, 06:43 AM
I guess i left that out of my original post. I have a multi column listbox with the same fields as the table i mentioned before. so its a listbox with 15 columns. I have a button that adds items to this listbox. when i am done adding items i want to be able to send the collection of items in the listbox to the table called project order, so that i can create a report that will be act as an invoice.

OBP
07-09-2009, 07:45 AM
So are these Items coming from another table or set of tables?
Why aren't you working directly with the ProjectOrder Table?

mpearce
07-09-2009, 08:45 AM
the ProjectOrder table is empty at runtime. it gets populated based on the items in the listbox.

I guess i am thinking of it like a shopping cart sort of thing. i want to be able to add items to the listbox and then have the collection of items show in a report that i can hand someone.

this is an app for a lighting company who sells low wattage energy efficient lighting fixtures. They wany an app for their sales guys to use at the client site. They want to be able to pick the existing fixtures and put in quantity, watts, and the hours the light will be on for. Then kilowats and kilowatt hours are calculated based on quantity, watts and hours. They will then choose a proposed fixture and the same calulation will run. after they have picked the existing fixture and the proposed fixture i have a button that adds that information to a listbox. i need to create an invoice, or report based on the contents of the listbox so that the sales guys can have something to give the customer.

I know that i can create a report based on a table. I'm just stuck on how to get the listbox collection into a table.

Is there a better way to accomplish this?

OBP
07-09-2009, 08:52 AM
Yes a Subform in Continuous mode based on the Table, so you are working directly with it.
After the report is run, delete the records in the tabel.

mpearce
07-09-2009, 10:02 AM
I am a little confused on how to apply that logic. maybe my file will help?

OBP
07-09-2009, 10:17 AM
It would.

mpearce
07-09-2009, 01:24 PM
here it is

OBP
07-10-2009, 04:49 AM
Mike, have a look at this version, I have created a Table based on your Main Form's Unbound Fields and then Bound them to the new Table.
It works a treat, there is no adding to do as it puts the Values Straight In, but obviously you could do with a Delete Record Button to remove them from the Table if necessary. However if you weren't happy with the Current Record you can just overwrite it anyway. After the Invoice has been Printed use a Delete Query to delete all the Records and Start Again.
Or add the Customer ID to the Table and keep the records as History.
You could use a Subform as I suggested and pass the values to it using VBA, but why bother?
I have put in 2 test Records.

mpearce
07-13-2009, 01:20 PM
your modification is pretty slick, however is it not exactly what i need. I fill in the text boxes and combo boxes, on the form called entry, and click to add the item to the list. I then need the contents of the listbox sent to the invoicedata table so that i can create an "invoice" (report) from that table.

OBP
07-14-2009, 03:03 AM
The Form that I provided just puts the data straight in the Report table, why do you need to put them in the List box first, it appears to be a redundant step.

mpearce
07-14-2009, 05:36 PM
the only reason i would want something like that is so the user can see the entire order before creating the invoice report. maybe a wrong item was entered or a wrong quantity. The form that you have does allow the user to see the data in the table but at a record by record basis.

This application is for a lighting company, so with each client there are multiple rooms and multiple fixtures. so i would like to have a way for the user to pick items from the drop downs and fill in the textboxes and then add those to a "container" whether it be a subform that is a table or something else. then i would need to create a report based on the invoice data table.

mpearce
07-17-2009, 06:18 AM
any thoughts on this?

OBP
07-17-2009, 10:43 AM
This is a start, it adds the first 3 fields to the List box Row source.