PDA

View Full Version : Help sending data to listbox columns



Austinl
06-25-2010, 02:19 AM
I had a listbox with 2 columns and i want to send the Dim [Price] into column 2, i've looked on google and have struggled to find a solution. Can anybody please help? (Tis for work) :)

Cheers
Lee

Imdabaum
06-25-2010, 08:13 AM
What's in column 1? You asked about Dim [Price], why don't you store the price in a table so it's accessible whenever you want without worrying about whether it's declared or not?

If you are going to join it on data from a table, you'll probably want a function getPrice() as Price that displays the price in a query, but that price is going to change I assume depending on what is in column 1. Right? So you'll need to getPrice(identifier as [Datatype]) based on the information in column1. Using the identifier, you could then calculate a Price and display that. (This will probably slow down the query...A Lot)

IE

SELECT Table1.Product, getPrice([Table1].[Product]) as Price From Table1
....

Function getPrice(p as String) as Double/Currency

getPrice = [logic for determining the price based on column1 information]

End Function




I would suggest storing the Price into a table with its associated [Column1] data. Whether you do it in a temp table that just gets deleted later, or a permanent table that gets updated at a certain point in the application, it'll perform better that way and you can ensure the correct data.

HTH

Austinl
06-28-2010, 01:42 AM
No no, ive got data in the first column thats just text, its the name of the product, column 2 displays the price, this is so i can do the totals easier because i want to add up all of the numbers in column 2 to get a total.

Imdabaum
06-28-2010, 01:57 PM
Then wouldn't you want to just sum the data in column 2? I don't understand what the Dim [Price] was about.
SELECT SUM(Column2) From Table1 and bind it to a textbox under your listbox.

Austinl
06-28-2010, 02:02 PM
Basically a current form pages price value, then shoves it in the list box after a button is clicked

Imdabaum
06-28-2010, 03:04 PM
I'll try and build a demo and see if I can post it for you to reference, unless you want to post what you have. Either way, I'll try and demonstrate it better than I can explain it.

Austinl
06-28-2010, 03:10 PM
Thank you :)