Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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 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…

777 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