DSUM with no results show as blanks - ms-access

I am experiencing a bit of a problem.
My textboxes populate based on DSUMS, but if someone doesn't take a payment they are not in the table so the textbox shows blank. However I was it to at least have a zero in it.
I have tried changing the default value but still shows as a blank
Help

A simple Nz(DSUM(stuff), 0) replaces all Null values with 0

Related

Autofilling my form in Access with the use of a Combo Box

I'm having a problem when I want to autofill my form in Microsoft Access. The idea is that I use a combo box to select a name. Then the onChange code of my Combobox automaticlly inserts all the other data in the proper field. I use this code on the Combo Box.
Private Sub cmbName_Change()
Me.tbPersonalNumber = Me.cmbName.Column(0)
Me.tbEmailadress = Me.cmbName.Column(2)
Me.tbBirthday = Me.cmbName.Column(3)
End Sub
This methode works fine for the personalnumber and the emailadress. But it doesn't work for the birthday date, it returns a null value but when I check my table there is is a date in the proper field.
Am I missing something? I tried everything but it wont work.
I was thinking that the problem is related to the birthday column being the last in the table. Or having the date type.
Thank you in advance for your time and efford!
Edit; The .Column(1) is missing because this is the name that is already inserted with the ComboBox.
There is some confusion caused by the wording of the question, I'll try to state back how I've interpreted and if I have it right it may lead you to an answer.
You have combo box called cmdName that is pre-populated with data from a table. The content of the combo box could look as below (you may have set column widths to zero to hide the data)
0001|Gary Evans|gary#email.com|01/Jan/1970
0002|J Rommers |JR#email.com |02/Jan/1970
When the user selects J Rommers Me.tbPersonalNumber is populated with Me.cmbName.Column(0) (0002) and Me.tbEmailadress is populated with Me.cmbName.Column(2) (JR#email.com) but Me.tbBirthday is not being populated with Me.cmbName.Column(3) (02/Jan/1970).
Assuming Me.tbBirthday is a text box with no code that might clear it out, I suspect the issue is within the combo box. Not being sure how your combo box is set up, I would suggets the following checks:-
In the combo box properties, does the Column Count equal 4?
In debug, with a breakpoint on Me.tbBirthday = Me.cmbName.Column(3), does it show you the date you are after?
If it is not there does the query that populates the combo box have it in?
Edit based on comments to help further: -
Change the query to SELECT Personel.PersonalNumber, Personel.Emailadress, Personel.Birthday, Personel.Name FROM Personel ORDER BY Personel.Name; this puts all the fields you want hidden at the front.
Change the column widths property of cmbName to 0,0,0, this first the ones you want hidden and leave the last one to fill the width of the combo box.
Ensure the column count property is still 4 as per the answer
Change your code as per below and Gustav's answer
Replacement code:-
Me.tbPersonalNumber = Me.cmbName.Column(0)
Me.tbEmailadress = Me.cmbName.Column(1)
Me.tbBirthday = DateValue(Me.cmbName.Column(2))
This accounts for the fields moving in the query and ensure the date shows as a date like you wanted.
Comboboxes (and Listboxes) always return a string, so convert that to a Date value:
Me!tbBirthday.Value = DateValue(Me!cmbName.Column(3))

how to solve SSRS Formatting issue?

Currently the data in field is coming like this 9646.88 and my requirement is
Remove decimal places and add comma for thousands e.g. 9,646
=IIF((RTRIM(Fields!COMPANY_NAME.Value))="VACANT","",Fields!BASE_RENT_PM.Value)
Please help, I am a newbie in SSRS.
Go to Properties pane when you select the textbox.
Then put this on Format property
#,0;(#,0)
Using Common Functions such as Text and Conversion functions shown in Expression window will give you the desired result.
For e.g,
Format(Int(9646.88), "#,###") // try "#,##0" which returns 0 if less than 1
where Int(9646.88) returns the integer portion of the number 9646 and Format(9646,"#,###") returns a string formatted according to instructions contained in a format String expression "#,###" which is a thousand seperator. Thus, it will give you "9,646".
So, in your case, try this,
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT", "", Format(Int(Fields!BASE_RENT_PM.Value),"#,###"))
Note:
Format(9646.88, "#,###") will return a rounded result 9,647 and
Format("VACANT", "#,###") returns just "#,###",
none of which may not be your desired result.
Have your Tried this?
=FORMAT(IIF((RTRIM(Fields!COMPANY_NAME.Value))="VACANT","",Fields!BASE_RENT_PM.Value),"#,###")
Should solve your issue.
Kind Regards
To add comma for thousands, you need to change your expression.
If you need output as 9,646 then try below.
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT","",Format(Convert.ToInt32(Int(Fields!BASE_RENT_PM.Value),"#,0;(#,0)")))
OR
=IIF(RTRIM(Fields!COMPANY_NAME.Value)="VACANT","",Format(CInt(Int(Fields!BASE_RENT_PM.Value),"#,0;(#,0)")))
Updated Answer:
As you want to handle null values as well I would suggest below way to achieve your goal.
Set Textbox visibility with below expression.
=IIF(ISNOTHING(Fields!BA‌​‌​‌​SE_RENT_PM.Value),True,False)
So if null value is there then it will show blank in the ssrs report.

SSRS 2008 Format a cell to blank if value is 0 or null or anything other than a number

I have a cell expression in which Im trying to force it to simply display an empty cell if the underlying value is something other than a number, is zero or null etc. There is no formatting in the textbox properties.
Surely there is something simpler
What I have now
=IIF(IsDBNull(ReportItems!YE_Goal2.Value) OR
ReportItems!YE_Goal2.Value = 0 OR ReportItems!YE_Goal2.Value Is Nothing,
"",ReportItems!Projected2.Value/ReportItems!YE_Goal2.Value)
When there is no value, it displays a 0 instead of being blank.
Try this:
=IIf(
Not IsNumeric(ReportItems!YE_Goal2.Value) or
IsNothing(ReportItems!YE_Goal2.Value) or
ReportItems!YE_Goal2.Value=0, "",ReportItems!Projected2.Value/
iif(ReportItems!YE_Goal2.Value=0,1,ReportItems!YE_Goal2.Value)
)
Note you have to validate two times ReportItems!YE_Goal2.Value=0, First time for control flow, the second time in order to avoid validator throw erros for division by zero.

SSRS IIF Multiple expression not working

Please see pic
For some reason my expression is not working and I cannot figure out why...
What I'm trying to do is check the UseByDate if it's blank set time to blank AND if pickeddatetime is blank (time field) also set to blank if not blank use pickeddatetime. However my expression doesn't seem to be working correctly for some reason?
=IIF(Fields!UseByDate.Value is nothing, nothing, IIF(Fields!PickedDateTime is nothing, nothing, FORMAT(System.TimeZone.CurrentTimeZone.ToLocalTime(Fields!PickedDateTime.Value), "HH:mm")))
I've checked the pickeddatetime value and it is definitely null for this row.
Replace Fields!PickedDateTime with Fields!PickedDateTime.Value
I think the way the expression is written isn't checking for nothing correctly. Try:
=IIF(IsNothing(Fields!UseByDate.Value)=True, nothing, IIF(IsNothing(Fields!PickedDateTime)=True, nothing, FORMAT(System.TimeZone.CurrentTimeZone.ToLocalTime(Fields!PickedDateTime.Value), "HH:mm")))

Cell displays #Error when I expect an INT in SSRS

I'm having a problem when trying to display a 0 when there is an occurrence of a special which I have listed in my data source
The normal sum computes fine and displays in the cells without the special day, but the cells which have a special day displays an #error
=iif(Fields!SpecialDay,
0,
Fields!NormalSum)
and then I have tried variations to get the integer, such as
CInt("0")
Fields!NormalSum - Fields!NormalSum
but I still get an #Error in the cells for which I wish to display a 0.
Any thoughts on this particular problem?
Many thanks
Ending up using
=iif(Fields!SpecialDay,
nothing,
Fields!NormalSum)
Better to do so in VB.
The problem is you are referring to the object Fields!NormalSum
You need to refer to its "Value" property Fields!NormalSum.Value