CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2011
    Posts
    2

    Unhappy Concatenate multiple rows

    Hi,

    Can you please tell me how to concatenate multiple row colums into one??
    My Report consists of several tables joined by their User Id.....so i have to link all of them with left outer join.

    For Example,

    Users.UserID Info.Mobile Company.M0dels
    1 Samsung 1
    1 Nokia 2
    2 Nokia 3
    2 LG 4

    changes into

    Users.UserID Info.Mobile Company.Models
    1 Samsung,Nokia 1,2
    2 Nokia,LG 3,4

    Here, Users, Info & Company are different tables left joined to Users..

    Please help mee...asap

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

    Re: Concatenate multiple rows

    Welcome to codeguru forums !!!

    To do that, you have to :

    a)- Group by Users.UserID
    b)- Create 3 formulas:

    1.-The first one, let's call it @null:
    Code:
    whileprintingrecords;
    stringvar names := "";
    Place it in your Users.UserID Group Header section, it will return you null.

    2.-The second one, let's say @comma_field:
    Code:
    whileprintingrecords;
    stringvar names;
    names := names & ", " & {Company.M0dels};
    Place it in your Detailes section which you can suppress; the formula will return you next: ,1,2 or ,3,4

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

    JG

  3. #3
    Join Date
    Jun 2011
    Posts
    2

    Re: Concatenate multiple rows

    thanks for the reply..

    But what does Mid(names,2) does??

  4. #4
    Join Date
    Jul 2005
    Posts
    1,083

    Re: Concatenate multiple rows

    It will display the variable 'names' from the second characters to the last
    (it will remove the first comma from variable 'names')
    try & you will see

    JG

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
  •  





Click Here to Expand Forum to Full Width

Featured