Results 1 to 10 of 10

Thread: How to put a grid/table in a crystal report

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    How to put a grid/table in a crystal report

    Hi. I am working in Crystal and I have some existing reports of ours that have been a great learning tool but I have a question what is the best way to do this.

    I want to generate a report of a customer and all their contacts. So this can be anywhere from 1 to an unknown number of contacts, but practically just a handful, let's say 5 or less. There will be a lot of other data on the report. The way I see we are doing this currently is with a subreport. For example, one existing main report we have wants to list a customer's systems so that is a subreport, and the subreport has a Page Header which is the names of the systems columns and Details which are the unknown number of systems rows. The subreport is pulled into the main report.

    I can't see another way to take a section and format it this way. In other words, if you run a query in SQL and say select * from tblCustomerContacts, I want the column names and then all the rows just like the resultset is displayed in SQL.

    I have no problem doing this as a subreport, just wanted to know this is the best way. I am not pivoting the data or anything, it's very straightforward, just a simple SELECT query. I don't think it's a cross tab.

    Thanks!
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  2. #2
    Fanatic Member
    Join Date
    Jul 2022
    Location
    Buford, Ga USA
    Posts
    630

    Re: How to put a grid/table in a crystal report

    So, you want to have a report where you can define which fields are displayed at runtime. You will need to look at dynamically creating a crystal report. It has been a while; I'll look at my old projects. I believe I have code that does this.

    This kind of does it https://www.codeproject.com/Articles...Report-with-C-

  3. #3

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Re: How to put a grid/table in a crystal report

    No, I must not have explained it correctly. I know the fields at design time.
    I am using a subreport. In all the research I did, that seems to be how it's always done. Thanks though.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  4. #4

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Re: How to put a grid/table in a crystal report

    If I may ask again, I still need help with this. And I can explain this better now.

    I'm attaching a subreport called SiteSub and how it looks in the CR designer. It was generated using the wizard as a subreport of SystemData.rpt

    Formerly the database allowed up to 4 access contacts. So there was one database record representing a site with four sets of these 3 columns: contact name, contact phone and phone type (business, cell, whatever). Of course this isn't the best database design so we've redone this with a 1:many table relation and now can have as many contacts as needed.

    So that is great but I don't know how to modify the report. Instead of that Access Contacts section on the top right, I need a grid of 0 to n rows. Does anyone have the answer how to do that? I believe I have to add on to the SiteSub subreport, but add on what? This goes back to my original question. I'd like to have a grid but CR doesn't seem to have that in any straightforward manner. And I can't do a subreport because I'm already working with a subreport.

    Thanks for any help.

    Name:  Site Sub in CR Designer.jpg
Views: 1175
Size:  28.4 KB
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  5. #5
    Fanatic Member
    Join Date
    Jul 2022
    Location
    Buford, Ga USA
    Posts
    630

    Re: How to put a grid/table in a crystal report

    Just place the new sub-report where you currently have the 4 hard coded fields.

    This is a super simple example; I made a table style sub-report, linked the id field in testable1 to partid field in testtable2, then positioned the sub-report to the right of the data from testtable1 in that details section. Am I oversimplifying your request?
    Attached Images Attached Images  

  6. #6

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Re: How to put a grid/table in a crystal report

    Good morning, thank you. Probably not oversimplifying my problem but I can't do a subreport because I'm already working with a subreport.

    SiteSub is already a subreport of SystemData. Insert -> Subreport is greyed out when I am working with SiteSub. I google this and it says you can't have a subreport within a subreport.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  7. #7

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Re: How to put a grid/table in a crystal report

    I'm thinking if I don't use the report wizard to create an embedded report, the subreport within subreport limitation may be removed? I am going to try it. I will post back later if it worked and what exactly I mean.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  8. #8
    Fanatic Member
    Join Date
    Jul 2022
    Location
    Buford, Ga USA
    Posts
    630

    Re: How to put a grid/table in a crystal report

    Wow, I missed that, sorry. Ugh so you probably have to reorganize the report to bubble up Details b (in the current sub-report) to the main report. So, you can have the contacts data in a sub-report. Place the current sub-report below this new section. It's hard to visualize anything else without the context of the complete report design.

  9. #9

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Re: How to put a grid/table in a crystal report

    OK, all my attempts have failed. I don't understand why it's so hard to find a solution . I can't believe I am the first developer to want to do this. It's simple - there's a single high level object called a system. Systems have sites - physical locations of equipment. Then these sites have access contacts so when our technicians are working on a problem at a site they know who to call. So I need to generate a report with that data. Isn't this equivalent to a company having departments and each department having employees? So you'd want to see a report for VB Forums. It has a department Reporting with employees jdelano and MMock. It has another department X with employees A, B, C, D. I feel like I'm just not coming up with the right search string in Google because how is this not a thing?

    I tried to fake Crystal out and I wrote a subreport SiteAccessContacts. It worked. Then I went into SiteSub.rpt and linked it to SiteAccessContacts and they worked. But then in SystemData.rpt, the top report, it only rendered SiteSub. So it does seem like truly Crystal doesn't let you have much of a subreport chain.

    I tried a Crosstab, out of desperation, but I'm not summarizing data so I think that's the wrong tool.
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  10. #10
    Junior Member
    Join Date
    Feb 2026
    Posts
    19

    Re: How to put a grid/table in a crystal report

    Your search string: cascading hierarchy of one to many relationships crystal reports (you are far removed from self proclaimed 'first dev to have ever ran into this' )
    Last edited by RedHeadedLefty; Feb 7th, 2026 at 08:31 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
  •  



Click Here to Expand Forum to Full Width