Author |
Message |
Andy K
Newbie
Joined: 21 Nov 2011
Online Status: Offline
Posts: 4
|
Topic: Filtering, Parameter. Posted: 22 Nov 2011 at 5:49am |
Hi,
I have the table that has MasterID and ToCompany columns. The requirements for the reports are:
1. Show only the items for a specified MasterID. The parameter must be set programmatically in code, the user can not change it on the report for security reasons. Also preferably the parameter should not be displayed on the report. 2. Optionally filter items by ToCompany. The list of companies should be filtered by specified MasterID.
I started with meeting the first requirement and have no problem handling it by itself. I set up the parameter MasterID, set the parameter in code, and then display the report. Since the parameter has been set already, there’s no prompt displayed to the user, the report is displayed to a user showing the records filtered by the specified MasterID. So far this is exactly what I need. Also, the sql query has the where clause for the MasterID. Note the parameter could be either static or dynamic, works the same way. I went with the static one for performance reasons. I have MasterID, I don’t need to retrieve the list of MasterIDs from the database.
Now I need to extend the functionality of the report to meet the second requirement. Here’s what I have tried:
- I added the second parameter ToCompany independent of the MasterID. It’s dynamic, optional. The first requirement is still met, everything works as described above. The user only prompted for the second parameter ToCompany. The report shows the records based on the user selection. The sql query has the where clause for the MasterID and optionally for ToCompany. Everything works as I needed except for one thing. ToCompany parameter displays the list of all companies for all MasterIDs completely disregarding the first parameter. I have tried this approach because I thought that after MasterID has been set, the sql query is re-generated right away and then the report would display the list for ToCompany based on the updated sql query. Clearly, that was the incorrect assumption.
- I removed all the parameters and created new cascading dynamic parameters MasterID-ToCompany. I set MasterID in code, and then display the report. However the user is still prompted for MasterID, MasterID that was set in code is not selected, the user has to select MasterID from the list. After the user selected MasterID from the list, ToCompany parameter displays the filtered list based on the picked MasterID. The report shows the records based on the parameters. So now the first requirement is not met. First issue is even though MasterID is set in code, it’s not selected in the list. Second, the user sees the complete list of MasterIDs and can selected other ones which is not acceptable at all.
- I’ve tried to play around with parameter options, but that did not work. I could not get better results then my first two attempts.
Please let me know if you have some ideas. Thanks in advance.
Edited by Andy K - 22 Nov 2011 at 7:53am
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
|
Posted: 23 Nov 2011 at 5:18am |
how about using a command object to select the ToCompany based on the static MasterID? you can link the command object to the tables and you can use the parameter to pull from this list. just a thought, I don't deal with the CR parameters as we developed wizards to assist/work the way we wanted. HTH
|
IP Logged |
|
Andy K
Newbie
Joined: 21 Nov 2011
Online Status: Offline
Posts: 4
|
Posted: 23 Nov 2011 at 6:59am |
Hi lockwelle,
First let me clarify, because I think I misled you into thinking that I have one static MasterID. I don’t. When I said I set up the parameter MasterID as static, I meant the option of report’s parameter (List of Values: static or dynamic). In fact, the user selects the master from the list to view it’s items. When the user wants to generate the report, the code grabs MasterID of currently selected master and supplies it to the report.
If I understood correctly, you’re suggesting to set up the command parameter for MasterID and hardcode the value for it. As you can see now, it’s not an option because I don’t have one static MasterID. And as far as I know, you can’t set the command’s parameters dynamically. Please let me know if you know the way to do that.
Actually the report initially was set up with the command object. But I have to get away from it for some reasons. One of them has to do with the parameters. Again I could not use the command parameters, because I could not set them dynamically. I set up the report parameters. But I could not find a way to pass them to the command. The sql query would be exactly as specified in the command. It would not get updated with the where clause for the parameters. So the report would retrieve all the records from the database and then filter them based on the specified parameters.
Thanks for the suggestion.
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
|
Posted: 23 Nov 2011 at 11:36am |
As I said, I don't deal with the parameters too much, but how about this... select the MasterID's desired (a static list in the command object) and then dynamically link them to the company's. Or select the companys and masters ids using the command object where the masterid are IN () a list that you enter. This would give a table that you can link to the physical tables and only display the values that the user is allowed to see. worth a try.
|
IP Logged |
|
Andy K
Newbie
Joined: 21 Nov 2011
Online Status: Offline
Posts: 4
|
Posted: 24 Nov 2011 at 5:10am |
MasterID's list is not static either.
I forgot to ask, you mentioned some wizards. Could describe in general what those are? And how they work with CR?
Thanks.
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
|
Posted: 28 Nov 2011 at 5:07am |
we have an application that drives our reports. The application uses a 3rd party tool that creates 'wizards'. We have built controls that assist in the selection of parameters and then pass the results to a stored procedure which creates the output table(s). The application then passes the results of the stored procedure to the report which then processes the report. No connection is needed for the report, as it doesn't 'pull' the data from the database, but rather the data is 'pushed' to the report. In addition, we don't have to use the CR parameter screen as the report doesn't need them. If the report needs to display/use the parameters, the values are either passed back as a separate table or can be appended to the stored proc output to return just 1 table. You can return multiple tables and link then in the report as well if you want. HTH
|
IP Logged |
|
Andy K
Newbie
Joined: 21 Nov 2011
Online Status: Offline
Posts: 4
|
Posted: 28 Nov 2011 at 6:16am |
Ok, I see. I was thinking myself about building the form in my application to gather the parameters, then pass the parameters to report and not use the CR parameters screen. Though, I have been avoiding that and have been using the report's parameters, why re-invent the wheel? Up until now I was able to work around whatever issues I had with the report's parameters. If I don't find the solution for this one, I might have to reconsider the creation of custom parameter screen.
Thanks for your input, appretiate it.
|
IP Logged |
|
lockwelle
Moderator
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
|
Posted: 28 Nov 2011 at 6:41am |
we have older reports that do exactly that...they just set the parameters in the report then have the report display itself. The advantage to the custom parameter form is that you can control how the user access it...CR doesn't know about application security (if you have any) and might show inappropriate options for the user, but with a parameter form, you can 'preselect' the valid options. and it looks like the rest of your application, and not CR's screen, which just isn't that pretty if you ask me.
|
IP Logged |
|
|