Solved

I'm using crystal reports and i'm trying to check the parameter to create a qeury....

Posted on 2004-04-16
3
283 Views
Last Modified: 2010-04-17
I'm new to crystal reports
I have five parameters which the user sets.
I have to check these parameters in case they are blank and search the database
for whatever the user asked for.
I want to create a string which will hold the query and then run the query.

I tried doing it in the "Record Selection Formula Editor", but when i try to create a string and fill it with the parameters values, it gives me an error.

My question is, is there any way to create a query and store it in a string variable from the values entered by the user, then run the query.


Thank You.
0
Comment
Question by:AlexTLyn
  • 2
3 Comments
 
LVL 42

Accepted Solution

by:
frodoman earned 50 total points
ID: 10846406
You can do this only if you are using the Crystal RDC and creating the report completely dynamically from an application front end - I'm guessing that you aren't doing this but let me know if I'm wrong.

If you're doing just an application front end to a standard Crystal Report, or you're working purely in Crystal then you can't do what you're trying to do, but you can accomplish the same result.

The key is to create your report to pull all of the data, and then use the "Select Expert" to filter the incoming data by setting conditions such as {tablename.fieldname}={?parameter1}, etc.  Depending on the version of Crystal you're using, the blank parameters may give you problems though - you might have to resort to bringing in all of the records and simply suppressing the unwanted ones.

If this isn't enough to get you started, let me know a little more about what you need to accomplish and also the version of CR you're using.
0
 
LVL 100

Assisted Solution

by:mlmcc
mlmcc earned 50 total points
ID: 10853815
Assuming you can build your report from an unfiltered query, try this.
To use this method you will need to be calling the report from an application
On the page where the user sets the parameter values add code behind to display button to test the "parameters".

dim strSQL as string
strSQL = ""

If txtName <> "" then
  strSql = strSql & " AND {View.NameField} = '" & txtName.txt & "'"
end if

If txtScore <> "" then
  strSQL = strSQL & " AND {View.ScoreField} = " txtScore.Value
end if

'Remove the leadin "AND "
if strSQL <> "" then
   strSql = mid(strSQL,4)
   crRpt.RecordSelectionFormula = strSQL
end if

' Open the report

mlmcc
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 10924505
Glad I could help

mlmcc
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoreUp challenge 14 48
sumHeights2  challenge 7 78
Magic Software info 18 105
python sqlite question 11 43
A short article about a problem I had getting the GPS LocationListener working.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now