How to use query's in Crystal reports passing parameters


I have been thrown into a task at work and I have had no experience with it.

I have a database of Articles with an Article ID and a query to return an article by entering the article ID in a parameter box.

My company want to move to an executable front end with the access backend because they want to use it on machines without access installed.

Basically, I need some guidance on how to create a crystal report showing data from a query where an ID can be passed from a datagridview on another form. (Hope that makes sense)

I am using VS2005 Professional edition.

I only have minor knowledge of VB

I already have a datagridview that shows a list of articles with a detail button. When this is clicked I want it to load the crystal report showing the data from that item.

Who is Participating?
frodomanConnect With a Mentor Commented:
You want option #4 - a combination of #3 and of what I pointed to the first time.

What you want to do is create a report that has a parameter for the article id.  The select expert in the report should select based on this parameter so you'll be passing in a single id and the report will select the record(s) related to that id.  Within the report you can insert detail sections so you'll have DetailA, DetailB, etc.  Put your first data field in DetailA and make it one row high but in the format options for the field check the 'Can Grow' box.  Put your second field in DetailB and repeat the process.  What this does is if the contents of the first field are 3 lines of text, it allows the field on the report to grow vertically and that will expand the vertical height of the DetailA section so the next field (in DetailB) will get pushed down the page.

That's the basics of what needs to be done with the .rpt itself.  The win_samples link posted earlier contains the code that you need to pass the parameter value from your application to the report.

Hopefully that gets you on track.

Download the sample applications here:

or here for Windows apps:

They're based on VS2003 but the same code should work.  There are several samples in there about passing parameters to a report.

I'm assuming you know how to design the report so that it pulls data based on the parameter and what you need help with is passing the parameter from the application?  If that assumption is wrong let me know and I can give help on the other end of it.
bryanfordAuthor Commented:
ive been thinking about it and maybe i am not going the right way about this.

Basically, my project is a really basic knowledgebase with articles, and the part that i am stuck on is displaying an article.

When the user clicks on a detail button in a datagridview from a different form, I need the article to come up containing all the data.

The problem I am having is that I cant use a form with labels because the text length can vary and can cause overflow problems. This is why i thought a report would be better but playing around in the designer sort of says this wont help me either.

Do you know the best way to show this kind of data? We have an internal web version of the knowledgebase and I would like it to look like this:

Each heading, Title, Problem, Cause, Solution, etc is a different field in the database.


Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

There are several approaches to this that I can think of.

1) Use banding in a heirarchal datagrid so users can drill into the knowledge base and see it all within the grid
2) Use a form with labels and move the labels as needed based on the length of the text (assuming this is a Windows application) or use a form with flowlayout the automatically position the dynamic elements (for a Web application)
3) Use a Crystal report with on-demand subreports.

Option 1 & 2 are .Net application solutions and although I can help somewhat they are better addressed in one of the .Net forums.

For option #3 you basically create a report listing the articles and create a subreport that displays the article content and is linked to the main report by article number (or title or whatever field is unique).  You make the subreport an on-demand type so it doesn't display in the main report but will open when the link in the main report is clicked.  Within the subreport you can use the 'can grow' property to resize the fields as needed and place fields in separate details sections to avoid overlap.

If you need additional help with option #3 I'm happy to assist.

bryanfordAuthor Commented:
Option 2 or 3 sounds the best way to go, however I must stress that this has to be idiot proof. (Its a windows application that is an offline version of our knowledgebase so the elderly can get help before calling our call centre).

So basically, what I am trying to say is that I would like to keep the datagridview form as the startup, then show the report by clicking on the detail button next to that article.

If option 3 still fits under this, would you be able to help me out?

Thanks for your help so far.

bryanfordAuthor Commented:
did as you said and does the job well enough :)

thanks very much
All Courses

From novice to tech pro — start learning today.