ssrs if - cannot print the requested value - reporting-services

I have the following iif
IIF(LEN(Fields!IDENTITE.Value)=0,"Known manager","Unknown manager")
Yet for some specific case, nothing is appearing (e.g. no known nor unknown)
I checked the results with a sql query and nothing is appearing (the result is below)
I amended my iif to reflect this case
IIF(COUNT(Fields!IDENTITE.Value)=0,"Known manager","Unknown manager")
Yet the same issue is appearing
Any ideas on the why?
Thanks
Update : I tried the countrows as mentionned by #breez and I got this error

One of the possible way to deal with the absence of rows is the following:
Click on the tablix , look for NoRowsMessage option and type the text you want (example: "No known managers")
Next time there are no rows, this message will be displayed
PS: It is only doable for matrix, list and tables not for textbox. For more info, click here

Related

How do I get the result from my sql query on my text box?

Using Access 2007, I created a form (f_login) and a query (c_login), and I want to get the result from my sql query and display on my form, via text box..
Here is my sql query (working) :
SELECT t_lvl.nr_lvl
FROM t_admin INNER JOIN t_lvl ON t_admin.nr_rf = t_lvl.nr_rf
WHERE (((t_admin.nr_rf)=[Forms]![f_login]![txb_user].[VALUE]) AND ((t_admin.psw)=[Forms]![f_login]![txb_psw].[VALUE]));
And I tried to put on my control source of my text box those codes, but none of them worked...
=DLookup("[nr_lvl]","[c_login]")
=DLookup("nr_lvl","c_login")
=DLookup("c_login","nr_lvl")
=DLookUp("[c_login]";"[nr_lvl] =" & [Forms]![f_login]![txb_lvl])
I really don't know why it doesn't work!
Test your DLookup expression in the Immediate window (you can go there with Ctrl+g).
See what you get after typing this in the Immediate window and pressing Return.
Debug.Print TypeName(DLookup("nr_lvl","c_login")), DLookup("nr_lvl","c_login")
You told us c_login is a query, showed us the SQL for that query, and confirmed the query returns the correct result. Since nr_lvl is a field returned from that query, I don't see why the DLookup would fail when the form, f_login, is open in Form View.
So see what happens with that DLookup in the Immediate window ... whether it returns no value, the wrong value, or an error message. Then you'll need to figure out how to change it to get the correct result.
OTOH, if DLookup gives you the correct result in the Immediate window, and the issue with the form is that the text box value doesn't update in response to changes in txb_user and/or txb_psw you should requery the third text box (the one which uses DLookup as its control source) from the after update events of those first two.

Type Problems with Filter Expression in SSRS

SQL Server 2008 R2, using BIDS to design the report.
I have a table and I am trying to only show a certain row. Maybe there are better ways to do this, but I am coming across an error with the filter expression and regardless of how I achieve my initial task, I'd like to understand the filtering.
I started with the filter expression (set to type "Integer"):
RowNumber(Nothing) = 1
This gave the error:
Cannot compare data of types System.String and System.Int32.
I found the solution to this is to change the 1 to "=1" as 1 is evaluated as a string.
So I then had:
RowNumber(Nothing) = =1
That changed nothing, I got the same error.
Then I tried to do that to the first part of the expression:
=RowNumber(Nothing) = =1
This changed the error to a deployment problem (still builds, which is frustrating):
Error pvInvalidDefinition : The definition of the report '/ReportName' is invalid.
I then tried using CInt on RowNumber:
CInt(RowNumber(Nothing) = =1
Then I can deploy it, but the error just changes back to the first one:
Cannot compare data of types System.String and System.Int32.
It seems no matter what I try here I either can't deploy the report or I get an error that I'm comparing a string to an int.
RowNumber returns an integer, so it seems like this should work. I've tried using the name of the dataset in place of "Nothing" but that doesn't change what I'm seeing.
I realize there are many ways to solve my initial problem, but I am curious as to why the filter expression is invalid.
Its better to hide a row with visibilty property. Just click on any text box and go to visibily tab . You can now click on show or hode and go to expression.
That default to Hide . So write an expression there to hide the row.
=IIf(NOT(RowNumber = 1),TRUE,FALSE)
Let me know if you get any error
RowNumber is not available to use in a Tablix Filter.
Using RowNumber(Nothing) <> 1 as a Row visibility property fixed the issue.
Using BIDS you are not given any error that indicates what the problem is, but importing the report to Report Builder and deploying it from there will give a more descriptive error that, in the end, helped me to solve my problem.

Access combobox value

I have a combobox, and a button, that makes runs a query with the values it gets from combobox, but it does not seem to get the right value.
I tried using
[Forms]![Kooli otsing]![Combobox]
or
[Forms]![Kooli otsing]![Combobox].[Text]
the query did not work, it seems like it does not get the value from combobox. because it worked with normal TextBox.
I ADDED EXPLAINING PICTURE!!!!!
ADDED PICTURE OF VBA EDITOR
ADDED PICTURE OF ERROR AND NO COMMENT AUTOCOMPLETE
Based on the latest comments you posted on your question, you want to use:
[Forms]![Kooli otsing]![Combo19].Column(1)
Here's why. You said you have the following settings for your combobox:
column count: 2
bound column : 1
row source type : table/query
row source: SELECT [Haridusasutused].[ID], [Haridusasutused].[Nimetus] FROM Haridusasutused;
Column count of 2 is telling Access to use the first two columns from your rowsource (the only two columns in this case). Bound column is telling access that the default value of the combobox should be the first column of the row source. In this case, that would be [Haridusasutused].[ID]. Often ID columns are autonumber fields.
The reason you were having problems is that [Forms]![Kooli otsing]![Combo19] was returning data from the ID column (most likely a number) not "Elva Gümnaasium". By adding the .Column(1) you are telling Access to choose the data from the second column (.Column is a zero-based array) of the rowsource, ie, "Elva Gümnaasium".
EDIT: Alternatively, you can change the bound column from 1 to 2 and leave the rest alone (ie, you won't need the .Column(1) part at all).
This works in my application:
[Forms]![Hour-registration]![mwkselect]
^form ^combobox
Maybe try this to refresh:
Me.Requery
Me.Refresh
Have you tried to step through debugger and search for the value through the watch window? For instance put a breakpoint into a button click event, then add [Forms] to the watch window and look into it.
You can use:
[Forms]![Form1]![Combo1].[Text]

format report group header

Thank you for your reply,
I have a report then contain 7 group levels. I want if a field that is in groupheader7 (ThirdCenterCode) was null, it’s group header ( groupheader7) visible property be set to No.
and it should be control for each rows. Because it my in another record, that field is not null and group header 7 should be shown.
I try this code in format property of group header 7, but it not work and return the below error:
Private Sub GroupHeader7_Format(Cancel As Integer, FormatCount As Integer)
If IsNull([ThirdCenterCode]) Then
Me.GroupHeader7.Visible = False
End If
End Sub
Run-time error ‘2465’:
Microsoft access can’t find the field ‘ThirdCenterCode’ referred to in your expression.
Thank you a lot
With best regards
Ehsan Shahidifar
e.shahidifar#yahoo.com
In the VBA of a report, you can't refer to fields in the reports underlying recordsource unless there's a control on the report that uses that field as its Control Source. This was not always the case.
So, if you want to check the value of Me!ThirdCenterCode, then create a control and set that as its ControlSource, and then sets its .Visible property to No.
Of course, if you already have a control with ThirdCenterCode as its ControlSource, that is not the answer, and it's more likely a case of simply misspelling the name of the field.
The error is usually true enough. Double check the spelling - it can be useful to use intellisense to find controls and fields associated with the current form or report, you can do this by typing Me. and seeing if it is listed.
Thanks for your replay.
I found that Cause of error message, was the wrong location of it. It should be locate on detail section of report. Then I locate it in OnFormat of detail section of report. I found that if only one record of first group be Null Access will not show the ThirdCenterCode Section for all rows of current first group data. And it is not that I want, because there are some rows of data that ThirdCenterCode field of them are not Null and should be shown.
For solving this problem I locate my code in OnLoad section of report and it solve my first problem,
But Led to another problem. In this section access doesn’t show me the ThirdCenterCode Group section if all of records were null and if Only one record was not null, Access show the ThirdCenterCode section. And it causes that one or more rows in my report became blank.
Finaly for solving this problem I Copy and Paste code Of OnLoad section of report to OnPrint of Detail of report. Disbeliefly I found that when report is shown, my last problem is not solved. But when I print report, my problem is solved. ( It means that if ThirdCenterCode is Null Access don’t show it’s section group , and if it is not Null Access show it for each record.)
Best wishes
Ehsan Shahidifar
e.shahidifar#yahoo.com

SUM() on a form footer resulting in #Error

I'm trying to display the sum of a field in a text box in the form footer. The field is not calculated in any way.
Here are a couple of the things I've tried:
=Sum([txtWeldInches])
=Sum([WeldInches])
=Sum(CDbl([txtWeldInches]))
=Sum(CDbl([WeldInches]))
...well you get the idea. Each iteration I've used results in the Text Box displaying #Error Without exception.
I've used similar constructs in different forms in the same project, so I'm not sure what the problem might be.
Has anyone run into this before?
EDIT:
I ended up writing a VBA routine to update the boxes when it was likely that they would be changed rather than trying to get a bound sum() function to work.
http://support.microsoft.com/kb/199355
All of the domain functions are based on the same query (over the underlying recordset). If one of the bound functions on the form has a binding error, all of the functions on the form will return an error.
In other words, make sure all your footer controls are resolving properly and not hitting any nulls.
If you use a SUM or AVG then make sure you are also using the Nz function:
ControlSource = =SUM(NZ([FIELD],0))
Is the field "WeldInches" existing in the data source for this form?
What datatype the field "WeldInches" is?
EDIT: I have looked at all your comments. If it doesn't work by databinding, try and use the unbounded way. At runtime, get the value of WeldInches using DSUM and set the footer textbox's value when the form loads.
Also, remember to update it at places where you think the SUM could change.
I had the same problem as Rister.
The source of the form was an underlying query.
I had a bound text box named txtQty on this form. Its control source was Qty (based on the underlying query of the form).
I created an unbound text box and entered =SUM([txtQty]) and received an error.
I tried various ways to find a solution and was very desperate.
Then I deleted the underlying query and created a new one using the same name and fields as before.
Then I entered =SUM([Qty]) into the unbound text box on the form and voila, it worked. Note that I didn't enter the name of the bound text box (txtQty) into the expression, but its control source (Qty). I don't know why, but it worked for me.
I know you said "Form" but for those who have issues with the Sum formula in an Access "Report" the formula has to be in the Report Footer NOT the Page footer. Took me a while to figure it out as Access defaults to only showing the page footer.
You want to sum by the name of the column in the record source: SUM([WeldInches])
Make sure there are no other textboxes with the name WeldInches.