Crystal Report 2008 Add Command Where Clause parameter - crystal-reports

Crystal Version - Crystal Reports 2008 Business Objects - XI
I have written a query to populate a subreport and want to pull in a parameter to that query based on input from a user. My question is, what is the correct syntax I need to put in the first line of the 'Where' clause to accept the parameter?
I created a parameter in Add Command it is called PickDate
Here is the query I am using in Crystal Reports:
select
table2.book_no,
table2.time_stamp,
table2.restdate,
a.timestamp,
a.event_type,
a.status,
a.people,
a.new_date,
a.comments,
a.operator_id
from table1 a, table2
where table1.book_no = table2.outage_no
I have tested the query, it is pulling all the data, now I just need help adding parameter to prompt user to enter datatime.

Did you try using the Select Expert in the subreport? You should be able to say field = {?PickDate}

Related

Passing result of a query as parameter in Crystal Report

I am new to crystal report, I have a report to generate which contains two queries.
I need to run the first query which returns a single column.
I need to fetch the result of the first query one by one and pass it as a parameter to the second query. And finally running the second query.
It would be helpful if anyone tell me the steps about how to do this.
I am using crystal report 2008, I hope the above mentioned information is sufficient, if not please let me know.
you need to use sub reports for this purpose...
Take query 1 in main repoirt and query 2 in sub report. Place the sub report in the section that is coming after the data in main report.
Then pass the filed of mail report to sub report using the sub report links and then apply condition on this field in sub report Record Selection Formula

Crystal Reports: Add a parameter to query

I'm using the Crystal Reports add-on to Visual Studio. The report calls a stored procedure with a whole list of parameters. I added an int parameter to the stored procedure, now I want to make the crystal report pass a 1 for that parameter.
How do I do that? When I go to database expert > Selected Tables - it just shows the name of the stored procedure. Where does it list the parameters?
If you already created the report and added the parameter to the stored procedure after that you need to use "Verify Database" to get the parameter to the report

Trying to remove exisitng parameters in Crystal Report 10 report by creating new subreport to provide the parameter data

Hello: I am trying to run crystal report 10 report from command line (and I'm new to crystal). The report has two date parameters ?from and ?to. I can query a different database to get the ?from and ?to parameters. So what I'm trying to do is get rid of the external parameters by generating the dates from within the report to replace/populate ?from and ?to.
Can I somehow add a sub-report to query Oracle to get the ?to and ?from dates? This new sub-report would need to run first since the other four reports (3 subs and 1 main report hitting SQL server) all use these date parameters?
Thanks for any help.
To the extent I know, Whether you use sub report of main report if a user needs to enter his own parameters to query the database then you need to create external parameters
Edit------------------------------------------------------------------------------------------------
Since you are trying to get the date input from different database... your approach is correct to create a sub report for this.
Make sure to place the sub report first in order from where you are taking the values.
Either use a shared variable or through parameter linking get the date values to main report and pass the values to remaining sub reports through linking option in sub report links.

Crystal Reports - Adding a parameter to a 'Command' query

Crystal Version - Crystal Reports 2008
Business Objects - XI
I have written a query to populate a subreport and want to pull in a parameter to that query based on input from a user. My question is, what is the correct syntax I need to put in the first line of the 'Where' clause to accept the parameter?
Here is the query I am using in Crystal Reports:
Select
Projecttname,
ReleaseDate,
TaskName
From DB_Table
Where
(Project_Name like {?Pm-?Proj_Name})) and
(ReleaseDate) >= currentdate
When you are in the Command, click Create to create a new parameter; call it project_name. Once you've created it, double click its name to add it to the command's text. You query should resemble:
SELECT Projecttname, ReleaseDate, TaskName
FROM DB_Table
WHERE Project_Name LIKE {?project_name} + '*'
AND ReleaseDate >= getdate() --assumes sql server
If desired, link the main report to the subreport on this ({?project_name}) field. If you don't establish a link between the main and subreport, CR will prompt you for the subreport's parameter.
In versions prior to 2008, a command's parameter was only allowed to be a scalar value.
The solution I came up with was as follows:
Create the SQL query in your favorite query dev tool
In Crystal Reports, within the main report, create parameter to pass to the subreport
Create sub report, using the 'Add Command' option in the 'Data' portion of the 'Report Creation Wizard' and the SQL query from #1.
Once the subreport is added to the main report, right click on the subreport, choose 'Change Subreport Links...', select the link field, and uncheck 'Select data in subreport based on field:'
NOTE: You may have to initially add the parameter with the 'Select data in subreport based on field:' checked, then go back to 'Change Subreport Links ' and uncheck it after the subreport has been created.
In the subreport, click the 'Report' menu, 'Select Expert', use the 'Formula Editor', set the SQL column from #1 either equal to or like the parameter(s) selected in #4.
(Subreport SQL Column) (Parameter from Main Report)
Example: {Command.Project} like {?Pm-?Proj_Name}
Select Projecttname, ReleaseDate, TaskName From DB_Table Where Project_Name like '%{?Pm-?Proj_Name}%' and ReleaseDate >= currentdate
Note the single-quotes and wildcard characters. I just spent 30 minutes figuring out something similar.
Try this:
Select Project_Name, ReleaseDate, TaskName
From DB_Table
Where Project_Name like '{?Pm-?Proj_Name}'
And ReleaseDate >= currentdate
currentdate should be a valid database function or field to work. If you are using MS SQL Server, use GETDATE() instead.
If all you want is to filter records in a subreport based on a parameter from the main report, it might be easier to simply add the table to the subreport, and then create a Project_Name link between the main report and subreport. You can then use the Select Expert to filter the ReleaseDate as well.

How to incorporate the use of SSRS Dataset parameters with Timestamp escape clause?

I've the following WHERE CLAUSE of a SQL Query String in the SSRS Dataset:
WHERE "Input_date" >={ts '2009-01-01'}
AND "Input_date" < {ts '2009-12-31'}
And now, I'd like to use report parameter to wrap up the dates in the SQL statement, i.e.
#indate1, and #indate2.
I've tried this, but error occurs:
WHERE "Input_date" >={ts #indate1}
AND "Input_date" < {ts #indate2}
Please kindly advise.
Thanks.
What have you done to add these parameters? I assume that you have altered the dataset query with the changes you have posted in your question. There are two more steps you need to perform to make this work:
Define a new parameter to the parameters folder. Right click the parameters folder and choose Add parameter. Specify which values you want the user to be able to select. Repeat for the second parameter.
Add the parameters to the dataset you are using for the report. This can be done in the parameters section when you edit the dataset. Add two parameters with the names #indate1 and #indate2, and set each parameters value to the parameters you defined in step one.
Alter the SQL statement as you described in your post. I would think that your SQL should look something like this (assuming Input_date is a column in your table):
WHERE Input_date >= #indate1 AND Input_date < #indate2
This is specific to the BIDS 2008 version of Visual Studio. If you are using report builder or something else, please let me know, and I can change the instructions a bit.