Concat multiple values of same field on 1 detail line
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Concat multiple values of same field on 1 detail line

  1. #1
    Join Date
    Aug 2011
    Posts
    5

    Concat multiple values of same field on 1 detail line

    Table 1 Table 2
    1 1 a
    2 1 b
    3 1 c

    I want to concatenate a b c onto a single details line for the value in Table 1.

    This is as far as I got but the array only ever returns 1 value and so the loop never works.


    Dim arrTestodes
    arrTestodes = array({Table2.Column2})

    Dim i
    Dim stringoftests
    i = 1

    Do while i <= ubound(arrTestodes)
    if i < 2 then
    stringoftests = totext(arrTestodes(i))
    else
    stringoftests = stringoftests + ", " + ToText(arrTestodes(i))
    end if
    i = i + 1
    Loop
    formula = stringoftests


    Where am I going wrong?
    Thanks

  2. #2
    Join Date
    Jul 2005
    Posts
    1,075

    Re: Concat multiple values of same field on 1 detail line

    Study the next solution, where we are concatenating a field and display the
    resulting string at group or report footer in only one line, perhaps it can help to resolve
    your problem

    To do that, you have to create 3 formulas:

    The first one, let's call it @null:
    Code:
    whileprintingrecords;
    stringvar names := "";
    Place it in your GH section, it will return you null.



    The second one, let's say @comma_field:
    Code:
    whileprintingrecords;
    stringvar names;
    names := names & ", " & {table.field};
    Place it in your Detailes section which you can suppress; the formula will return you next:
    , Jules, Christina, Paul


    and the 3rd formula, let's call it @final (or whatever you like):
    Code:
    whileprintingrecords;
    stringvar names;
    Mid(names, 3);
    Place it in your GF or report section.
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  3. #3
    Join Date
    Aug 2011
    Posts
    5

    Re: Concat multiple values of same field on 1 detail line

    Ahh, I understand the logic now, thanks for your help!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center