Using iff expression in rdlc report with null check keeps giving errors - rdlc

In a rdlc report i'm using an expression to hide the row visibility.
If the expression is true the row is hidden.
The value of the field can be "Ja", "Nee" or Null. Only if it's "Ja" the row must be shown and the expression result should be false.
The expression
=Iif(Fields!Vleugel.Value Is Nothing,true,false)
is working but when I want to add the "Ja" condition like:
=Iif(Fields!Vleugel.Value Is Nothing,true,Iif(Fields!Vleugel.Value.Equals("Ja"),false,true))
it's causing an error like "Object reference not set to an instance of an object." when the field is null.
Can't figure out what's wrong since it's looks simular to examples I found.

If you use the Row Visilibily property you don't have to write an iif statement, it is enough to give the expression that will hide the row, try this:
=Fields!Vleugel.Value Is Nothing

Related

DLookup returning True for some values, and False for others

I am writing a program, and I need to be able to check whether a certain 'tag' exists, by looking at all the 'tags' in the column 'CowTagMain' of the 'CowTable' table.
The code I am using is,
DLookup("[CowTagMain]", "[CowTable]", "[CowTagMain]") = Tag ...
Where tag is a String, TagMain is the column, and MainTable, is the table I am fetching data from.
I am getting inconsistent results, when I try this with 18C, it returns true. While if I try this with 18, it returns false.
I would assume I am fundamentally misunderstanding how to use DLookup, but after searching the internet for hours I cannot understand what I am doing wrong.
Even just pointing me in the right direction would be very appreciated! I am new to working with Access and VBA.
The search criteria is not within the function WHERE CONDITION argument.
The field is text type so need apostrophe delimiters.
Consider:
If IsNull(DLookup("[CowTagMain]", "[CowTable]", "[CowTagMain]= '" & Tag & "'")) Then

SSRS Calculated field with IIF expression gives #error when the condition is false

Hello I'm fairly new to SSRS and I'm working on making my first report for work. It has been going fine until today when I needed make a textbox in Tablix handle both a numbers calculation and text. A column in my SQL table that was previously a purely number field now has n|a for certain rows. So I wrote the following expression to handle those n|as. When the proceeds field is numeric the formula works, but when it's an n|a it shows up on the report as #error and I can't figure out why. I've removed all formatting from the textbox to the same result.
=IIF(Fields!Proceeds.Value<>"n|a",Fields!Proceeds.Value / Fields!DealBalance.Value,"n|a")
As TnTinMn explained, IIF always evaluates both the true and false part of the expression.
The simple fix is to do something like
EDIT Revised due to update from OP
=IIF(Fields!Proceeds.Value<>"n|a",VAL(REPLACE(REPLACE(Fields!Proceeds.Value,",",""),"$","")) / Fields!DealBalance.Value,"n|a")
This simply strips out the $ symbol and commas and then converts the text to a number using VAL(), if the text is not a number it will return zero which will not cause an error as the false part of your expression would give 0/DealBalance.

Conditional Formatting in Access with function in VBA

I'm familiar with programming in general but not with Access forms or VBA.
I have the conditional formatting working. Now I need to make it respond to the result of a custom VBA function.
Let's say there is a limit, based on the customer, to how many times something can happen.
The label will show the count, "Trip 3 of 5".
When we get to 5 of 5 it should be yellow and 6 of 5 should be red.
Note that I want the conditional formatting rules to be in Access, not in VBA. VBA just returns the value we test in the condition.
I don't see how to use the result of a VBA function in the conditional formatting expression, but it seems like you can use variables.
I tried
TripCountValid: GetTripCountValid(ID)
and then used TripCountValid in my condition, but that didn't seem to work.
GetTripCountMsg and GetTripCountValid are in the Orders module because that is where GetBillAcctMsg is, which I am emulating.
I could move it to the code-behind for the form.
My MsgBox in GetTripCountMsg gets called but not the one in GetTripCountValid.
A function can be referenced in Conditional Formatting. Use the Expression Is: option. Assuming your function returns a Boolean (True/False), the CF rule would simply be:
Expression Is: GetTripCountValid([ID])
Set the desired formatting to display if the function returns True. Or if you prefer to change display for False:
Expression Is: NOT GetTripCountValid([ID])
If those expressions are not explicit enough use = sign with whichever Boolean value you prefer.
Expression Is: GetTripCountValid([ID]) = True
If function returned something other than Boolean, use the last syntax to compare with whatever parameter appropriate for situation. The point is, the expression must evaluate to True or False.

SSRS syntax error with countdistinct iif

I have an SSRS report where I want to count specific results from the larger query (Overall Total - then of those total "Open" and total "Closed"). I'm trying to use the expression:
=CountDistinct(IIF(Fields!CaseStatusCode.Value='OPEN', Fields!CaseID.Value, Nothing))
But whenever I run the report I get:
There is a syntax error in the Value expression for the textrun ‘Textbox24.Paragraphs[0].TextRuns[0]’: ‘)’ expected.
I've added and removed multiple ) but the error persists. I've also tried the expression in different textboxes and the error continues (just changing the name of the textbox it's in). What am I missing?
Solved it. Apparently I am supposed to use " instead of '. Corrected code below.
=CountDistinct(IIF(Fields!CaseStatusCode.Value="OPEN", Fields!CaseID.Value, Nothing))

How to hide RDLC Table Column if no data is present in all the Rows with Expression?

I would like to hide the entire column including the header if all the rows under that is null or of no values with expression in an RDLC Report.
I have tried the expression
"=IIF(IsNothing(Fields!de_projectactivityidname.Value), True, False)"
inside the "Visibility" of the Column property.
I would like to do this without any report parameters.
any help is appreciated.
Vinu
I think you were on the right track, but likely the field is never going to be null/nothing. Instead, it's likely to be an empty string.
This should work:
=IIF((Fields!de_projectactivityidname.Value = ""), True, False)