On my report I have two parameters.
One is for the selection of an order number from a list (dropdown list) and the other is for typing an order number. The idea is to have the end-user either select the order number or type it, not both...
Is there a way I could empty the textbox when a list item was selected and vice versa, i.e. selecting an empty value from the dropdown list once an order number has been typed? I thought about using code but it would be impossible to determine which of the two parameters to use once the "view report" button has been pressed.
Any other approaches to this situation are very welcome.
Thanks in advance for any replies.
Define the parameters
Let's assume the first parameter that allows the user to enter the order number is called typed_value and the second parameter that allows the user to select an item from the list is called list_value.
Prevent list from being used if value is typed in
Add the following to the where clause of the query that populates the list_value
WHERE #typed_value IS NULL
This will prevent any records from being returned when the typed_value is not NULL, blocking the customer from selecting an order from the list if they have already typed in an order.
Update list_value with typed_value
The above code will only remove the list items, but to get the list to populate with the typed value add this union to the query that populates the list_value
UNION SELECT #typed_value WHERE #typed_value IS NOT NULL
If the user leaves the typed_value NULL then they can select any value from the list_value. If the user types in a value, the list will automatically be replaced with their typed_value.
Which value to use?
You can power your report filter off of the list_value and ignore the typed_value because if the user enters any value in typed_value, the list_value will be updated to the typed_value.
Smooth out the UX
Make sure the parameter typed_value allows null value. It may be a good idea to set the default value of typed_value to NULL so that the user can see the list values when the report first loads.
Also setting the default value of the list_value to #typed_value will automatically set the list_value to whatever value a customer types in.
Related
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.
In a form, I am displaying rows of data in the detail section.
Around 5% of the rows might actually have a float value in one column that I need to be displayed as a combobox. The column in question results from a left join, so it may have a float, or it may be null with no existing record behind it. I don't want to have 100000 rows added to a table just to show a zero in the combobox on the outside chance that a user actually displays that particular record. Yes, I can add the rows, then delete them later, but that seems stupid. For the life of me, I cannot figure out how to get the combobox to default to a zero for each row, and still be selectable. Basically for each row, show the value if there is one, zero otherwise, and let the user select a new value if they want.
The VBA side is easy. I can totally create the row if a non-zero value is selected, and delete the row if the user changes it to 0. Ideal would be to bind a combobox to NZ(myField,0), or something similar. When I tried that, the combobox was not selectable.
Right now my combobox is selectable, allows the users to change the value, but shows a blank, not zero if the column is null.
The SQL the form is bound to:
SELECT dbo.PersonClasses.ClassID, dbo.ClassDates.ClassDate, dbo.PersonClassHours.ClassHours
FROM dbo.PersonClasses
INNER JOIN dbo.ClassDates ON dbo.PersonClasses.ClassID = dbo.ClassDates.ClassID
LEFT OUTER JOIN dbo.PersonClassHours ON dbo.People.PersonID = dbo.PersonClassHours.PersonID AND dbo.ClassDates.ClassID = dbo.PersonClassHours.ClassID AND dbo.ClassDates.ClassDate = dbo.PersonClassHours.ClassDate
I am looking to represent ClassHours as a Combobox for each record on the form with valid selections being 0,.5,1,1.5,2,2.5. To keep it simple for the users, I want 0 to be preselected. This is how it looks now:
You could set the Format property of the combobox to
#;\0
This will display a zero if the field value is Null. Otherwise the actual value.
Other properties which will also need to be set are the Row Source Type to Value List and Row Source to 0;0.5;1;1.5;2;2.5
Using a function, such as Nz(), in your query to change the value of the field, actually creates a new field, which is read-only.
In your case you need the field to be updateable, so one of your options is to play around with the Format propery, or Conditional Formatting.
I have a report I need to develop where all Quotes should be listed where a specific Product is present. The product can be identified based on Product ID/Price/Product Name etc. I was looking to develop one report where all there fields are present as part of a dropdown. When the user selects one value such as Product ID and enters a value in the text box next to the ID, the report is filtered on this parameter. If the user selects name, the name can be entered in the text box and the report is filtered based on the Vendor ID etc.
Is there a way to do this? I have the parameters showing up next to each other instead.
It is doable if I understand correctly and here are the steps for achieving your report purpose.
I will use a simple query as an example data set for your reference.
1.Create source and datasets, in this example I skip the data sources and here is the short query for my exmaple
SELECT * FROM Table
WHERE
(ID = #ID or #ID = '')
and
(Name = #Name or #Name = '')
2.Add another dataset named Control, the query for Control is:
SELECT 'ID' as option
UNION
SELECT 'Name' as option
The purpose of creating this dataset is to provide the available values later when you need to choose either name or ID.
3.After step1, you should already have two parameters generated by system, which are ID and Name, if not, create them by yourself and go to each parameter page, DO MAKE SURE CHECK Allow blank value''
4.Create the 3rd parameter called Control, go to parameter setting page, go to Available Values, Choose Control dataset, Choose option (which is the customize column name you set in Controldataset) for both Value field and Label field
5.Go to ID parameter setting page, go to Default Values, choose Specify values, click fx, type this:
=Switch(Parameters!Control.Value="Name","")
Click ok
6.Go to Name parameter setting page, go to Default Values, choose Specify values, click fx, type this:
=Switch(Parameters!Control.Value="ID","")
Click ok
The ID and Name expression are correct, not set wrong
7.Change the parameter order to make Control on the VERY TOP, no matter ID or Name comes for the 2nd, but Control should be in the 1st place.
8.Drag and drop a table, place Name and ID. Preview the report, at this time, only Control will be available for you to choose value, choose either ID or Name to see the difference. When you choose ID, Name will be gray out, only ID light up and type any ID you want, actually, what the system does internally is passing the "" (blank value) to Name, that is why you need to make sure the Name parameter could accept blank value. Same for selecting Name
Update me if you have any run time issue
I have a program with multiple cascading parameters. I’m puzzled why, if they’re all set up the same way (Available Values, Default Values, Refresh), they don’t display the same way. In the images you can see that Job Type, Program Type, and Program Name all show the default ‘All selected’. But Job Name is empty. If I click on the down arrow, the values are all there and selected. (see second image). Is there any way to fix this?
i think, in your Job Name collection.. there is some blank/empty record. the solution could be either you restrict those values or in parameter select option "Allow Blank Value"...
All the best!
From memory this can happen if the query that populates the available or default parameter values includes a NULL in the result set.
Because your dropdown list has so many label values in it, the concatenation of those labels is violating the maximum size allowable by that SSRS control. This is why the text "disappears" from the dropdown box when choosing (Select All). I have been unable to determine the exact character limit of this. If you want to spend some time confirming this, it's possible to begin with (Select All) and begin unchecking items until you see the text reappear in the box.
Because this limit is not configurable, one possible course of action to solve this would be to, on the query that populates that list of parameters, truncate those values down to a small number of characters so that when they're concatenated, that limit is not violated.
This could mean that you have Values set but do not have Labels set for the available values of the Job Name parameter. Go to the parameter properties and select "Available Values". If "Specify Values" is selected, then you need to enter Labels for each Value. If "Get values from a query" is selected, then you just need to select a Label field from the drop down.
I have a report which returns list of product names and other product specs. This report currently has different search options. My users now also want to be able to search by product number by putting in multiple product numbers.
How can I add a filter by product number which is an optional multi-value textbox?
I have tried to add a multi-value textbox. The report doesn't seem to work when no values are entered. If I put one or more product number in the text box, it seems to work fine. Is there a way I can tell the report doesn't filter on the Null value parameters? Or any other idea to work with optional multi-value parameters?
Here is the setting for my multi-value textbox
Name = ProductNumber
Prompt = Product Number
Data Type = Text
Allow Blank Value (checked)
Allow Null value (not checked)
Allow Multiple Values (checked)
Here is the data set filter
Expression = [ProductNumber]
Operator = In
Value = [#ProductNumber]
Thanks
TL
I think you should trick the dataset filter by:
Expression should check to see if the parameter is blank and if so give expression a 1 else the field.
Value should do the same check and if parameter is blank set value to 1 else set it to the parameter.
But keep your operator.
Alternatively you could do this similarly in the SQL and with more flexibility and performance.
So as you've seen in your own testing, at least one value must be selected with multi-value parameters. You can't set Allow null value to true at design time and if you run a report without selecting any values it will throw an error message.
So you can't really have a report where users can run it with no values selected.
Taking a step back, what you're trying to achieve when ignoring the parameter is to include all Product Numbers by default. So why don't you set the parameter to have a default value of all Product Numbers selected? That way, users can just ignore and leave them all ticked if they don't want to filter by Product Numbers. Seems like a good workaround to me.
To do this, set the default value for the parameter using the same dataset that populates it:
All Product Numbers are now selected and users only need to take action if they want a subset of these returned.