Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    AlliCrader is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jul 2017
    Posts
    12

    Calculated Field on Form, loop options?

    Hello All,



    I have built a form that has a subform and they are linked by RECNO. The subform can have one or multiple entries. I am trying to calculate a field that will pull all of the entries into it, not just one. I have figured out how to successfully pull the first record that matches into it, but I cannot figure out how to pull the rest of them. I know that this would typically probably need a loop of some sort, but I am not familiar with VBA and I cannot figure out how to do this in access.

    In the photo I have attached, it shows my field I am trying to enter this in at the bottom, I have got the first one in there, but how do I get the additional ones? The recno is equal on all three of these.

    Can anyone help?
    Attached Thumbnails Attached Thumbnails access.PNG  

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    So you want the data from all 3 sub records concatenated together? I suspect you could modify this to return multiple fields:

    http://allenbrowne.com/func-concat.html
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    AlliCrader is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jul 2017
    Posts
    12
    Yes, that is what I am trying to do. Is there a way to do this within access instead of visual basic?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Not that I can think of, perhaps somebody else knows a way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    AlliCrader is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jul 2017
    Posts
    12
    I am trying to use this but no matter what I do to fix syntax I either get #Name? or just nothing.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Without knowing your table structure and seeing your effort to use it, hard to say why you get an error. Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    AlliCrader is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jul 2017
    Posts
    12
    I final got it, but now I am having a whole different issue. My condition is not working. It is pulling everything. Below is my code. I need it to only do it if [RECNO]=[Line Total Query]![RECNO].

    =ConcatRelated("[Line Total Query]![Line Item]","[Line Total Query]","[RECNO]=[Line Total Query]![RECNO] ","[RECNO]"," ")

  8. #8
    AlliCrader is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jul 2017
    Posts
    12
    they are auto number fields by the way

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You missed the concatenation. Try


    =ConcatRelated("[Line Item]","[Line Total Query]","[RECNO]=" & [RECNO],"[RECNO]"," ")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    AlliCrader is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jul 2017
    Posts
    12
    Perfect! Thank you!

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    AlliCrader is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jul 2017
    Posts
    12
    Thanks! I am now getting and error when I first start a new record because the RECNO is not there yet, do you know if there is a way around that?

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Untested, but try:

    =ConcatRelated("[Line Item]","[Line Total Query]","[RECNO]=" & Nz([RECNO], 0),"[RECNO]"," ")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    AlliCrader is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Jul 2017
    Posts
    12
    Thanks! Works like a charm.

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problemo!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 05-22-2017, 05:59 AM
  2. Replies: 2
    Last Post: 12-30-2014, 01:32 PM
  3. Replies: 1
    Last Post: 08-25-2014, 01:23 PM
  4. Replies: 1
    Last Post: 04-21-2013, 03:20 PM
  5. Format options in combined Form field
    By perry in forum Forms
    Replies: 0
    Last Post: 03-06-2009, 04:53 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