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
Solved

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

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…

860 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