Results 1 to 7 of 7
  1. #1
    tmartin is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    37

    Want to update Textbox with the Sum of data inside a Listbox


    In a form I have a list box that is populated from a query. There are two columns in this list box and will display two columns of numbers (currency)
    I need to add up the contents of each column and present that to the user in a single text box for each column. I have written VBA code that will accumulate each list and compute a correct result.

    I tried AfterUpdate event on the listbox but that will not trigger an event to run the VBA script. Any suggestions on how you would solve this problem?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Code in AfterUpdate event can certainly call a procedure that does the calcs. What code did you 'try'?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    tmartin is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    37

    Added DB Example

    Need to accumulate content in Listbox columns. How would you approach this?
    Thank you

    Tom
    Attached Files Attached Files

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Perhaps like this:
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    tmartin is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    37
    I do notice that sometimes the text boxes do not get updated and just left blank. I am not sure why since the text box update is dependent upon a query and not the content of the list box. Now once I select the text box the value is then displayed. Any ideas?

  6. #6
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    I do notice that sometimes the text boxes do not get updated and just left blank.
    When does this happen. What happens that would make the text boxes need to update.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  7. #7
    tmartin is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    37
    I made the text boxes unbounded and then added a call on form onload to populate all text boxes using a common sub method
    These boxes were read only. I have not done a lot of testing to make sure this resolves the problem.

    I create an onclick event for all text boxes and then moved your DSum function inside. Then when the form is loaded all txt box
    controls are called that update the text boxes when the window is displayed. The only drawback there does seem to be a performance hit.
    Not sure of another to resolve the issue since I am a novice.

    Thanks

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

Similar Threads

  1. Replies: 8
    Last Post: 03-24-2015, 09:56 AM
  2. Replies: 2
    Last Post: 03-23-2014, 06:50 AM
  3. import all data from listbox to a textbox
    By mikael in forum Access
    Replies: 8
    Last Post: 09-09-2012, 07:16 PM
  4. Update form when data collected from Listbox
    By Evetsllub in forum Forms
    Replies: 1
    Last Post: 06-10-2010, 05:33 PM
  5. Replies: 0
    Last Post: 12-14-2009, 09:57 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