Results 1 to 7 of 7
  1. #1
    USMCTL is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    12

    How to put in formula that will add values of selected fields in criteria.

    Hello, looked for question in the forum for previous post, didnt see anything. I am trying to make a distribution report. User prefers to use a file that has sales for every month. There is a field for each month sales. Normally, on my query I would have an sum field with the formula like [TABDDATA_IVVSUM]![IVSQ01]+[TABDDATA_IVVSUM]![IVSQ02]+[TABDDATA_IVVSUM]![IVSQ03]. Sum months 1-3 basically. Since I know how to use access, I would go in that query and just change the number of months and run query. However, I am making a form that is user friendly for my coworkers who have no clue about access and it would be overload for them to try to do that. On the form, i would like the, to be able to choose the months (fields IVSQxx + IVSQxx ect) on a list box, then have those months (values in the field) be summed as if it would in my formula field. How can I make this possible?

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    You're not saying the months are listbox columns (i.e. 4 months, 4 columns)? If so, that's not good. If they are list items and a user is picking from the list, you need to iterate over the selected items and build an expression with + in between the items. That assumes the items are field references or numbers. If you search 'loop over listbox selected items' you'll find lots of code examples.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    USMCTL is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    12
    They are columns. This is coming off a table that has a row for each account. User will select only one account he/she enters in text box. A column for month 1, month 2, month 3..ect. Each one has the number of items sold for that month for that row(acc) How do i make something like i would in the query for a formula builder [TABDDATA_IVVSUM]![IVSQ01]+[TABDDATA_IVVSUM]![IVSQ02]+[TABDDATA_IVVSUM]![IVSQ03] . Is it possible I could just run all sales for an acc,...using normal main form. Then a separate form or popup that allow user to add certain colums together?

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    Something's not right there. Probably lack of db normalization. You will have to loop over the field or columns which IIRC are both zero based.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    USMCTL is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    12
    I see I can make an expression in the list box. How to I let the user choose what months to add together?

  6. #6
    USMCTL is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    12
    I can do it in a query just cant figure out how to do it in a form. eek

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    You can retrieve list item column values using code, but you cannot select items from listbox columns using mouse/keyboard. You can only select listbox rows. If you select one or more rows, you can loop over the columns and string values together but trying to select only certain columns would be tricky. The whole thing would be so much easier if your design was normalized. Either it is not, or it is but something you've done with the listbox rowsource has "de-normalized" your data. The months should be in rows, or you ought to step back and create a better approach.
    There is a field for each month sales.
    That seems to be the crux of your problem. See at least the first 2:
    Normalization Parts I, II, III, IV, and V
    http://rogersaccessblog.blogspot.com...on-part-i.html
    and/or
    http://holowczak.com/database-normalization/

    Entity-Relationship Diagramming: Part I, II, III and IV
    http://rogersaccessblog.blogspot.com...ng-part-i.html

    How do I Create an Application in Microsoft Access?
    http://rogersaccessblog.blogspot.com...cation-in.html
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 1
    Last Post: 02-04-2015, 03:12 PM
  2. Replies: 1
    Last Post: 10-29-2012, 08:15 AM
  3. Replies: 0
    Last Post: 03-08-2011, 05:56 PM
  4. Replies: 1
    Last Post: 08-17-2010, 02:33 PM
  5. Replies: 1
    Last Post: 03-27-2010, 06:13 AM

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