SSRS Check if Parameter exists - reporting-services

I have a report where the user must enter an order number, this then populates tables and charts etc.
What I need to know is how do I go about informing the user that they have entered an invalid order number?
so a sort of 'IF #ORDERNO IN (SELECT DISTINCT ORDERNO FROM ORDERS) then the data will be displayed else a textbox will show at the top of the report saying Invalid Order No.
I could provide them with a list of OrderNumbers to select from as the parameter but there's too many to make this feasible.
I know you can add a Textbox with an expression with an IIF and check a value, but is it possible to check that value exists in a dataset?

Is norowmessage property of the table works for you?
Select your table->press F4-> Put relevant message under
NoRowsMessgae property

Create another parameter and have it populate the order # if it exists.
Parameter1: Enter Order: 54455
DataSet2: Select 'Valid Order' As "Confirmation" from Order_Table where Order_number = :Parameter1
Set Default Value of Parameter2 to display Confirmation value as Default
This way, they'll know if they have the right order even before they run the report.

Related

SSRS Optional parameter with empty field

I need to run the report, without selecting anything, with parameter field blank, and be able to view all the data.
the problem is that it necessarily asks me to enter a value (all or multi values).
Who can help me?
If you make sure that you do the following...
Set the parameter to "Allow blank value" and/or "Allow null value" depending on what datatype it is.
Set the default value to Blank (="") if applicable
If you have a list of available values set, make sure the default value is included.
The following example uses sample data from sample database and contains just a list of company names and their ID's.
The main dataset query filters the data based on 2 parameters (one is text the other id numeric to show different scenarios)
This is the dataset query
SELECT CustomerID, CompanyName
FROM [AdventureWorksLT2019].[SalesLT].[Customer2]
WHERE CompanyName LIKE '%' + #pSearch + '%'
and CustomerID > ISNULL(#pID, 0)
ORDER by CompanyName
The report design looks like this with 2 parameters defined
The first parameter is text and has "Allow blanks values" checked, the Default value is set to an expression =""
The second parameter is an integer, This time we have set "Allow null value" on but we have not set a default value.
Note: Neither parameter has any available values set...
When the report is run I get the following results without pressing anything.
Only if I manually set any of the parameters do I need to press View Report, but when the report first runs, there is no need to click anything.
If the above does not help, then show how the parameter(s) are setup up, what types they are, what the available values are and what the default values are.

ssrs:add null value to multi value parameter didn't work

in order to allow a selection of null value in multi value parameter in SSRS project
we can use the query for the data set
Select ID,Value From SpecificTable
Union All
Select NULL,'Other'
in order to let null value returned from parameter when 'other' string is selected from parameter available selections
note:in available values section at parameters properties i have chosen ID Column as Value Field and Value as Label Filed
i have tried the previous query with no be benefit ,the string 'other' doesn't appear as available selection for the parameter when i preview the report
are there any additional configurations that i should apply ?
I don't think you can do it this way... that's why "Allow Nulls" is an option.. what you can do is set the ID value for Other to some obscure value.. like -99.. which the actual ID from the specifiectable can never be.. and modify your stored procedure to say..
where (#id = sometable.someidcolumn or #id = -99)
This should in effect ignore the ID selection! Unless you want it to do something else of course.. then you code accordingly in the where clause.

If Parameter A = (Select All) then Default Parameter B to "Y"

I have a report i have been asked to write from a procedure i did not create the procedure has 2 parameters for each of the options.
#AreaID
#AreaID_All
So They coded this way if you wanted to search for a specific Area id you would input the Area ID into #AreaID and then input "N" Into #AreaID_All.
If you wanted to show all then you would input NULL into #AreaID and "Y" into #AreaID_All.
It was also requested that there be a multiselect dropdown for the #AreaID.
I have this part down, now im stuck on how to say if the User Selected (Select All) in #AreaID then Default the #AreaID_all to "Y".
Any Ideas?
You can create another dataset that returns the count of AreaID rows you are passing as available values to the parameter.
Then use it to compare against the Parameters!AreaID.Count function.
#AreaID_All set expression would be something like this:
=Switch(
...
...
First(Fields!CountofAreaID.Value,"CountDataSet")=Parameters!AreaID.Count,"Y"
)
This means Select All option was select.
Also I strongly suggest you have an internal parameter to validate the data your #AreaID_All is getting from the user.
Let me know if this helps.

SSRS Report Builder, is there a way to show values in filter?

Is there anyway to show the user what values are in each field so they can filter on these values?
How is the user supposed to know what values they want to filter if they can't see the values?
If I correctly understand what you are asking:
1) Set up a data set to retrieve the available values for your filter
SELECT DISTINCT MyFieldValue FROM MyTable
2) Create an SSRS parameter which will be used for the user to select a filter. Set it up to allow multiple values, and set the available values to use the data set created in step 1. Let's call this Step2Parameter.
3) Create your core data set for the report, and use the parameter from step 2.
Select MyID, MyFieldValue, Name, Blah FROM MyTable WHERE MyFieldValue in ( #Step2Parameter )
You can repeat this with multiple fields.
Does that get you in the right direction?
Also, make sure that in the Parameter Properties (right click your parameter and select Parameter Properties), that "Select Parameter Visibility" in the "General" menu is set to "Visible".

Add "All" option to ComboBox used to filter for report in MS Access

I'm trying to follow Microsoft's example on how to add an "All" option to a ComboBox in Microsoft Access, but their article does not do an adequate job of providing guidance, aside from specifying the code.
What I'm trying to do is build a form that allows a user to select an option from a ComboBox (the options are generated from records in a table), and then build a report filtered based on the user's selected option. The ComboBox consists of 2 columns: the primary key/ID of the records and their displayable names.
I can't understand the VBA code Microsoft provides enough to figure out what is going on, but I would like the "All" option in my ComboBox to either have a blank primary key/ID, or one that = 0. That isn't the case, as selecting the "All" option when using the form results in the error message "The value you entered isn't valid for this field". This leads me to believe that the "All" text is getting filled into the primary key/ID column instead of the display column. The example instructs me to assign the display column number as the "Tag" property of the ComboBox - and in this case, my display column number is 2. However, this (and pretty much any other value I add) results in the aforementioned error message.
Any idea if Microsoft's example is even applicable to my case, or do I need to adjust their code somehow?
Check the Control Source property of your combo box. Sounds like it may be bound to a field in the form's record source. If you make it an unbound control (nothing in the Control Source property) you should be able to select any item from the combo's Row Source without Access complaining at you.
Say your combo's Row Source is a query like this:
SELECT id, disp_name
FROM YourTable
ORDER BY disp_name;
You can add an "all" row with a UNION query:
SELECT id, disp_name
FROM YourTable
UNION ALL
SELECT TOP 1 0, "**ALL**"
FROM AnyTable
ORDER BY disp_name;
AnyTable can be just that. If you happen to have a table which contains only a single row, use that one ... and you wouldn't even need the TOP 1 part. Just try not to use some ReallyBigTable as AnyTable.
Edit: Actually some ReallyBigTable would be fine if it has a primary key or other unique field which you can use in a WHERE clause to retrieve a single row:
SELECT id, disp_name
FROM YourTable
UNION ALL
SELECT 0, "**ALL**"
FROM ReallyBigTable
WHERE pk_field = 1
ORDER BY disp_name;
UNION ALL will return all combined rows. If you have any duplicate rows, you can thin them out by using just UNION instead of UNION ALL.