| Author |
Message |
TBT1
Newbie
Joined: 18 Oct 2012
Online Status: Offline
Posts: 6
|

Topic: Record selection with Multiple possible parameters Posted: 18 Oct 2012 at 4:43am |
|
If {?Job} = {Job.Job} then {?Job} = {Job.Job} and {Job_Operation_Time.Work_Date} >= {?Start Date} and {Job_Operation_Time.Work_Date} <= {?End Date} Else If {?WorkCenter} = {Job_Operation_Time.WC} then {?WorkCenter} = {Job_Operation_Time.WC} and {Job_Operation_Time.Work_Date} >= {?Start Date} and {Job_Operation_Time.Work_Date} <= {?End Date} Else If {?Employee} = {Job_Operation_Time.Employee} then {?Employee} = {Job_Operation_Time.Employee} and {Job_Operation_Time.Work_Date} >= {?Start Date} and {Job_Operation_Time.Work_Date} <= {?End Date} Else {Job_Operation_Time.Work_Date} >= {?Start Date} and {Job_Operation_Time.Work_Date} <= {?End Date}
The above is a statement I am currently using to sort my report, it partially works..
The end goal is to be able to sort by any of the following
Start and End Date, or Job and Start and End Date, or Employee and Start and End Date, or Work Center and Start and End Date.
Currently what happens is the report requires the Start and End Dates, which is good. But if I attempt to put an employee number (Ex 000030) in as a part of the sort, I still receive all of the same information as before, with only the date range.
Meaning all of the records for the date range that was entered in the prompt.
This occurs for all of the other "optional" sorts of Employee, Job, and or Work Center.
Eventually a co-worker may want to sort by Job which would then pull all of the entered information against the job.
Any help would be greatly appreciated.
Edited by TBT1 - 18 Oct 2012 at 4:45am
|
IP Logged |
|
|
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 18 Oct 2012 at 4:50am |
Please clarify,
is this for sorting purposes or selection purposes or both?
It sounds likeyou only need to filter on the dates but have a dynamic sort on date/job/employee or work center...
|
IP Logged |
|
TBT1
Newbie
Joined: 18 Oct 2012
Online Status: Offline
Posts: 6
|

Posted: 18 Oct 2012 at 4:55am |
|
It is ideally for selection purposes. The report sorts by Employee number which is like "000030"
The report currently shows all of the information, that is also a part of the selection field.
IE
If I have a report run with 10/18 to 10/18 it will show the Jobs, Employee name, and qty's run etc.
But want I need it to do is to specifically give me only the information I input into the Prompts. If the Prompt for Job Number is blank, ignore it, but if the Employee number is not blank, give my that Employees information for the date range, and only that employee.
Edited by TBT1 - 18 Oct 2012 at 4:55am
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 18 Oct 2012 at 4:55am |
what version are you running?
|
IP Logged |
|
TBT1
Newbie
Joined: 18 Oct 2012
Online Status: Offline
Posts: 6
|

Posted: 18 Oct 2012 at 4:59am |
|
Crystal reports XI
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 18 Oct 2012 at 5:01am |
XI does not allow for optional parameters so you need to use a substitute like an 'All' option.
Are you using dynamic params, static lists you are building or just letting the user type something into a blank field? Edited by DBlank - 18 Oct 2012 at 5:02am
|
IP Logged |
|
TBT1
Newbie
Joined: 18 Oct 2012
Online Status: Offline
Posts: 6
|

Posted: 18 Oct 2012 at 5:06am |
|
The parameters are user entered. Dates, Job, Employee and Work Centers
Because we have a very large database that is being pulled from, a list record wouldn't work.
By an all option what do you mean?
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 18 Oct 2012 at 5:16am |
Since you cannot leave a param blank the user needs to enter some value. You have to come up with a value for each param that is equivalent to a blank. It gets trickier for user entered params because you cannot control for typos or train them all to use the 'correct' language.
Usually report writers stick with a dynamic LOV and add an extra value like 'NONE' or 'ALL' so the user knows how to 'answer the parameter entry questions'
Versions 2008 or up allows for params to be left blank which is easier to deal with.
A very large DB can still use dynamic LOVs.
basically here is how you would write youe select statement
{Job_Operation_Time.Work_Date} in {?Start Date} to {?End Date} and
({?Job} = 'All' or {?Job} = {Job.Job}) and ({?WorkCenter} = 'All' or {?WorkCenter}={Job_Operation_Time.WC})
and
({?Employee} = 'All' or {?Employee} = {Job_Operation_Time.Employee})
|
IP Logged |
|
TBT1
Newbie
Joined: 18 Oct 2012
Online Status: Offline
Posts: 6
|

Posted: 18 Oct 2012 at 5:20am |
|
OK thank you for the tip,
Just a question, I've tried to create a date range param as you have it shown "{Job_Operation_Time.Work_Date} in {?Start Date} to {?End Date}"
and the formula editor tells me I have an error.
Is that convention used in newer versions of Crystal only?
Additionally,
Did you give me the entire promp code that I need, it looks complete to my "New to Crystal Eyes"
programming isn't my best skill set.
Edited by TBT1 - 18 Oct 2012 at 5:20am
|
IP Logged |
|
TBT1
Newbie
Joined: 18 Oct 2012
Online Status: Offline
Posts: 6
|

Posted: 18 Oct 2012 at 5:23am |
|
It works,
My god your great.
Do you think I should set a default value for the optional fields to "All" and change the description to say that they can change it?
Edited by TBT1 - 18 Oct 2012 at 5:24am
|
IP Logged |
|
|
|