Access 2007 IIF statement not working 100% of the time - ms-access

I'm having difficulty with an IIf() statement as the control source of a textbox on a report.
The IIf() statement does work on my report, just not 100% of the time. I have taken a screenshot of the problem below.
On my report, if the Supply Locator = the OHQ Locator, I want the Supply Qty to = the OHQ for that locator, else put 0.
The control source of the textbox is =IIf([SUPLYLOC]=[OHQLOC],[QOH],0).
The screenshot shows what lines work and which don't by the green and red rectangles.
Any info or insight appreciated.

I believe the problem was the grouping on the report in trying to work with the IIF statement, but I was able to get it to work with the below. I actually had to reference the field on the report.
=DLookUp("QOH","qryPickList","[SUPLYLOC]=[OHQLOC] AND [COMPNUM] = Reports!rptCustomPickList_main!COMPNUM")

Related

Property/ function to find empty subreports and hide them in Access report

How can I tell if a subreport is empty? Is there a property or function I can use to check whether there is any data in the subreport? I want to write a subroutine that says
If IsEmpty(subreport) Then
subreport.Visible = False
Else
subreport.Visible = True
End If
That, combined with making the subreport small and allowing CanGrow would help me display only the values that do exist without taking up space on my report if the subreport is empty. Ideally, I'd also be able to hide the label of the subreport if it's empty.
If the VBA code is going to be on the main report then you would use,
Me.subreport.Report.RecordsetClone.RecordCount
to get the number of records. If the code is in the sub-report then you only have to write,
Me.RecordsetClone.RecordCount
If you have any issues with this or need an explanation leave a comment and I'll get back to you.

Conditional formatting not working on subform

I have a form in form view with a continuous subform in it.
I have a conditional statement in the conditional formatting for the control in question (which is a combo box) on that continuous subform. This conditional, when evaluates true, disables the combo control for that record:
[Forms]![frmCommuteInSub]![ctlDate]<getStartDate()
I have also tried this statement:
[Forms]![frmCommuteInSub]![ctlDate]<#12/01/2016#
Interestingly, this does not work in the main form... but if I open the subform by itself this formatting works just fine.
Anyone have an idea of what may cause this? I really need this to work in the main form.
PS. I'm using Access 2013. I am proficient in VBA or any other language if that helps.
Try using the DateDiff function and see if that works.
If DateDiff("d",[Forms]![frmCommuteInSub]![ctlDate],getStartDate()) > 1 then
The way I see it you have 2 options, it just depends on which suits you and your project.
Complete the conditional format based on a main form / subform relationship using the expression builder.
Complete the conditional format based using single value evaluation. However, in order to do this you will need to make sure the value you are evaluating is part of the table or more likely query you have the form b
Whichever route you choose, make sure to ensure that the variables or controls you are evaluating are producing correctly formatted results. That's half the battle!
More info:
http://www.iaccessworld.com/conditional-formatting-for-subform-or-datasheet-form/
https://bytes.com/topic/access/insights/868555-demo-conditional-format-subform-unlimited-colours

ssrs if - cannot print the requested value

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

Adding Fields into an expression in an SSRS 2008 report

Thank you in advance for taking your time to answer my question.
I am having trouble with expressions in the SSRS reporting system.
The Field I am adding required fields from the dataset I provided in the report, however when I try to preview the report I get the Following message:
"A Value expression used for the report parameter ‘Policies_Total’
refers to a field. Fields cannot be used in report parameter
expressions."
This is my expression:
=IIF(Sum(Fields!policy_id.Value, "DataSet1") Is Null, 0, Count(Sum(Fields!policy_id.Value, "DataSet1")))
That was suppoed to be converted from Crystal reports which has the following expression:
If IsNull ({usp_rep_agent_cases;1.policy_id}) then
0
Else
Count ({usp_rep_agent_cases;1.policy_id})
Any help is much appreciated.
Thank you
I think it may be as simple as understand that a 'parameter' should be passed into SSRS before fields are created for the most part. If this parameter is DEPENDENT on the value of something else first being chosen you cannot list it first as the field is not yet populated to my knowledge. It appears you are trying to use an expression to count something from a field from a dataset when you just make a dataset and reference that field directly. So instead of trying an expression you may choose a few other options instead:
Choose on the left pane of your parameter 'Available Values' selected 'Get values from a query'. You may use your query which is a 'dataset', value is self explanatory, label is what the end user will see display.
The option 'Allow null' value will accept a null value
You may run into situations where multiple datasets may need to be used, multiple selects or querying objects. In my experience with SSRS it gets mad at times when you try to reference a dataset used to display data with a dataset used to determine an event or action. SSRS also gets relativity slower the more Expressions you do so doing a whole report with nothing but expressions versus taking the power of the built ins of the RDL language is not really worth it IMHO.
For SSRS expressions you need to use IsNothing for NULL checking, something like:
=IIF(
IsNothing(Sum(Fields!policy_id.Value, "DataSet1"))
, 0
, Count(Sum(Fields!policy_id.Value, "DataSet1"))
)
In fact the whole expression seems a bit odd; what are you specifically trying to achieve with your expression? Are you just trying to count non-null values?
=Sum(IIf(IsNothing(Fields!policy_id.Value), 1, 0), "DataSet1")
Also, your error seems to be saying that a parameter is referencing a field when this isn't allowed, which may not be solved by changing syntax; I think more information about what you're trying to achieve is required here.

SQL 2008 Reporting Services Question - tablix visable

I have a report that has two tablix on it. I'm trying to control the visibility of the tablix using an expression. When i hard code in a boolean value of 0 or 1 the visibilty works. When i put in something like the following
=cbool(iif(First(Fields!bGeneralQuestionDisplayed.Value, "ClassificationNarrowed")=1 ,1,0))
it does not work. I've profiler to verify that the query is running and returning the results. I've also created a text field on the form rumming the same expression.. the result is a 1 or a 0.
anyone have any idea as to what might be causing the issue.
thanks
shannon
According to the FIRST documentation, the second parameter represents a group. Do you have a "ClassificationNarrowed" group defined?