Results 1 to 4 of 4
  1. #1
    Suttoa is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2019
    Posts
    7

    adding a column from mulitple listboxes, and putting the total into a textbox

    Hello,



    I am having trouble with a spot of VBA, that should be easy..

    I have a Form with a lot of list boxes (32)… each has queries calculating different fields but their columns line up. I am hoping to sum up column(7) of each listbox, and entering the total into a textbox on the same form


    I have tried using various scripts to pull the list box value (it is a double.. more specifically currency), as an example I was going to use this:

    With lstbox
    MsgBox (.Column(6))
    tbTotalRRPREM = .Column(6)
    End With


    in troubleshooting the above message box states the value is null, but the lstbox is definitely not null..

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    My guess is that you're not aware that the column property of a listbox or combo is 0 based, thus column(6) is the 7th column. What's missing from your post is how many columns are in each control.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    can you set each listbox to be bound on col(6) (remember : col 7 in form view, col 6 in vb)

    then just sum all the listboxs
    lstBox1 + lstbox2 + lstbox3...

  4. #4
    Suttoa is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2019
    Posts
    7
    Thanks guys, It was the column format.. inside my brackets I was just putting the column number, not the row.. I ended up using something like "variable = listboxname.column(7,0)" and that worked... silly but it worked.. thanks for the help though!

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

Similar Threads

  1. Replies: 3
    Last Post: 10-17-2018, 04:51 AM
  2. Replies: 35
    Last Post: 03-19-2018, 12:06 AM
  3. Replies: 3
    Last Post: 09-23-2017, 08:16 AM
  4. Replies: 4
    Last Post: 05-22-2015, 05:52 AM
  5. Adding mulitple records from same form
    By mikehorse in forum Forms
    Replies: 5
    Last Post: 09-22-2014, 06:33 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