Solved

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

Posted on 2004-04-16
3
288 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

920 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

16 Experts available now in Live!

Get 1:1 Help Now