I thought this would have been a simple task, I want to change the font colour of a field in a Crystal Report if it differs from another field value. Essentially I have two numeric fields and want to change the font to red if they are different.
I have used the Format Editor>Font>Color formula method. I have tried the following code/s ...
if ToNumber({Petty_Cash.PettyCashandMoneyIntroduced}) = ToNumber({Petty_Cash.LessTotalPaymentsByPettyCash}) Then crBlack Else CrRed;
if {Petty_Cash.PettyCashandMoneyIntroduced} <> {Petty_Cash.LessTotalPaymentsByPettyCash} Then crRed Else CrBlack;
Neither of these will work, if I add a numeric value it will work....
if {Petty_Cash.PettyCashandMoneyIntroduced} >=90 Then crBlack Else CrRed;
I'm hoping it's something simple that I have overlooked.
Any ideas please?
Related
I have written the following expression to give me the number of days between a date and today.
=IIF(Fields!First_Check_Start_Date.Value = nothing,nothing,datediff("d",Today,Fields!First_Check_Start_Date.Value))
The output is correct but is bracketing the number
ie. (292) instead of 292
Any help as to why this is
if you are using text box to display your result, check what is the type of your text box. Make it as number and look for it's format and set to correct
Else you could also format like below
=IIF(Fields!First_Check_Start_Date.Value = nothing,nothing,Format(datediff("d",Today,Fields!First_Check_Start_Date.Value),"##"))
So it appears that whilst viewing in SSRS Report builder the numbers are bracketed (292), however once export to either csv or excel the bracket disappears and is replaced bi a minus -292 which is correct
Thanks
Ok, the problem is that im working in a excel userform, but i cannot find a way to do a comparation between a textbox value and a cell value and if some statement is meet it will write other value to another textbox (the program is has already been made with the use of excel macros, but i wanted to make it look better, and im trying to use the userform)
Here is the code i am trying to run
Select Case (TextBox1)
Case Is <= Sheet2.Cells(3, 8)
TextBox21 = 4
End Select
(When you run the code its does nothing)
Do i need to do something else to make it work?, because im using the same excel file of my tables to make the userform,if i'm confusing something please do let me know.
Thanks for your answer and sorry for my English.
If CInt(TextBox1.Value) <= CInt(Sheet1.Cells(1, 1).Value) Then
TextBox2.Value = 4
end if
The problem is that you are trying to compare strings, when you should be comparing numbers. You just need to convert the values to an int. You might also want to put in a little more validation to ensure that textBox1 and cells(1,1) are in fact numeric values.
I've been searching for a solution to this for a while and have been unsuccessful in finding. Essentially, I have the user of my document populating fields in a user form that my code then puts into the appropriate cells. One of these input fields is a number but, no matter how I instruct excel to format the cell, it still is text in the end and I can't perform any calculations. I'm sure this is probably a pretty simple fix but I've been unsuccessful so far in finding a solution. As always, any help is appreciated!
thanks!
You need to convert the value from text to a numeric type before putting it into a cell.
Assuming your textbox is called txtNumber and you're outputting to cell Output!A1, the code would be:
Sheets("Output").Range("A1") = CDbl(txtNumber)
Other conversion functions you might want to use are CLng (convert to Long), CInt (convert to Integer), CDec (convert to decimal, useful for currency values).
This code will raise an error if the user types a non-numeric text value into the field. You should validate on the textbox's Change event and disable the OK button if invalid data is inputted.
I'm trying to format some cells in a Reporting Services report that will contain DateTime? values - or not.
If the underlying data has a NULL for that DateTime?, I'd like to show nothing (empty cell) - and if that data source contains a value, I'd like to show the date in short date format (dd.MM.yyyy in my locale).
So I tried to put this formula into the relevant SSRS cells
=FormatDateTime(Fields!DatumBSE.Value, 2)
but now I'm getting 01.01.0001 for all NULL dates....
I can't seem to wrap my head around how to do this in a SSRS (VB) formula.... I tried using IsNothing() but that doesn't seems to really help - I can detect a NULL, but how to I tell the cell to show an empty string in that case?
Solution:
I ended up using this function:
=IIF(IsNothing(Fields!DatumBSE.Value), "", FormatDateTime(Fields!DatumBSE.Value, 2))
Seems to work just fine for me now.
I just tested the following expression and it replaced the null date with an empty string:
=IIF(Fields!DatumBSE.Value is nothing, nothing, FormatDateTime(Fields!DatumBSE.Value, 2))
The other suggestion that I would make is that you could format the date to the correct format in the report dataset by placing a CASE expression around the date value.
use a code like this:
If(isNull([date field]),Null, elsequote)
I have problem in generate report. I use crystal report 8.5 with vb.net 2008,what I want is when I generate report it will appear red value, if the value is more or less than actual value else it will give default value but when I put this code it give me wrong result
If {Intake.wheatType} = {Spec.WheatType} AND
{Intake.HB43} >={Spec.M_Min} AND{Intake.HB43} >={Spec.M_Max} Then
Red
Else
DefaultAttribute
this report is related with two tables, which is table Spec and table Intake. Could anyone help/teach me how to fix this problem
When determining whether a value is between a minimum and maximum, the logic will be:
Is the value greater than the minimum and is the value less than the maximum?
Actually you can create a Formula Field for that,
From Field Explorer, right click Formula Field
A popup window will appear, type the name of the formula you want.
in the Formula Editor insert you custome formula
Code:
If {Intake.wheatType} = {Spec.WheatType} AND {Intake.HB43} >={Spec.M_Min} AND {Intake.HB43} >={Spec.M_Max} Then
Red
Else
DefaultAttribute
Then click OK. Drag the newly created field on your report. And that's it.
For more info, see this: Adding Formula Field