Consulting

Results 1 to 7 of 7

Thread: Help sending data to listbox columns

  1. #1
    VBAX Regular
    Joined
    Jun 2010
    Posts
    6
    Location

    Help sending data to listbox columns

    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

  2. #2
    VBAX Expert Imdabaum's Avatar
    Joined
    Jun 2006
    Posts
    652
    Location
    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
    [VBA]
    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


    [/VBA]

    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
    Someday I'll understand everything...
    Even then...I'll still pretend I'm a beginner.

  3. #3
    VBAX Regular
    Joined
    Jun 2010
    Posts
    6
    Location
    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.

  4. #4
    VBAX Expert Imdabaum's Avatar
    Joined
    Jun 2006
    Posts
    652
    Location
    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.
    Someday I'll understand everything...
    Even then...I'll still pretend I'm a beginner.

  5. #5
    VBAX Regular
    Joined
    Jun 2010
    Posts
    6
    Location
    Basically a current form pages price value, then shoves it in the list box after a button is clicked

  6. #6
    VBAX Expert Imdabaum's Avatar
    Joined
    Jun 2006
    Posts
    652
    Location
    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.
    Someday I'll understand everything...
    Even then...I'll still pretend I'm a beginner.

  7. #7
    VBAX Regular
    Joined
    Jun 2010
    Posts
    6
    Location
    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •