Results 1 to 2 of 2
  1. #1
    Xonos is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2012
    Posts
    15

    Summing All Values in Specific Column on a Listbox

    Hello again everyone! I have a syntax issue that seems to be stumbling me... I have written a "Calculate Weight" function tied to a button Click event and the purpose of this is to calculate the product weight of all products assigned to an order (which are displayed in the listbox).



    So this is how the listbox looks (all fields are shown, none are hidden with column width 0".)

    ID Product Name Container Quantity Weight
    442 Product Test 1 Syram Wrap 2 8
    231 Product Test 2 Product Box 4 22
    55 Product Test 3 Product Box 6 442








    Anywho, the problem seems to be somewhere in my code because when I click Calculate Weight - it returns the weight value of the item on the bottom of the list only. It doesn't seem to sum them all together. Does anyone see anything wrong with my code? I am a newb and this isn't "my" code more than it was just stripped from some example.

    Code:
    Private Sub bttnCalculateWeight_Click()
    Dim listrs As Integer
    Dim listsum As Integer
    Dim x
    
    DoCmd.Requery "listBOLProducts"
    listrs = Me!
    [listBOLProducts].ListCount
    x = 1
    Do
    listsum = (Me!
    [listBOLProducts].Column(4, x))
    x = x + 1
    Loop Until x = listrs
    Me![inputTotalWeight].Value = listsum & " Lbs."
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    listsum = Listsum + Me.listBOLProducts.Column(4, x)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Summing all values from a certain date
    By juliorevka in forum Access
    Replies: 3
    Last Post: 02-13-2012, 10:02 AM
  2. Replies: 1
    Last Post: 12-08-2011, 08:03 AM
  3. Summing a column
    By nashr1928 in forum Forms
    Replies: 2
    Last Post: 05-10-2010, 05:42 PM
  4. Issue summing two field values
    By w2vijay in forum Reports
    Replies: 4
    Last Post: 02-10-2010, 01:53 AM
  5. summing values associated with date ranges
    By wdemilly in forum Reports
    Replies: 0
    Last Post: 07-17-2009, 01:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums