How to use query's in Crystal reports passing parameters

Posted on 2006-06-13
Medium Priority
Last Modified: 2012-06-21

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.

Question by:bryanford
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 42

Expert Comment

ID: 16902145
Download the sample applications here: http://support.businessobjects.com/communityCS/FilesAndUpdates/vbnet_web_samples.exe.asp

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.

Author Comment

ID: 16907033
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: http://www.bryanford.info/screenshot.jpg

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


LVL 42

Expert Comment

ID: 16907139
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.

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.


Author Comment

ID: 16907212
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.

LVL 42

Accepted Solution

frodoman earned 2000 total points
ID: 16910790
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 vb.net code that you need to pass the parameter value from your application to the report.

Hopefully that gets you on track.


Author Comment

ID: 16926371
did as you said and does the job well enough :)

thanks very much

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question