Solved

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

Posted on 2004-04-16
3
295 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
[X]
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
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 116
Plain Text Editor for iPad 6 105
object oriented design (python) and documentation tools 2 104
what is the best Integrated development environment 2 41
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.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user 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…

730 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