We help IT Professionals succeed at work.

Crystal reports format number

Mittensonmaui
on
I have the following problem when the value is returned to the screen the number show like 2,009 how do I rid of the comma? Is there a format function?

Dim MonthInt as number
Dim MonthString as String
Dim yearString as Number
MonthInt = Month({StaffProjVar;1.Begin date})

MonthInt = (MonthInt + 11)

If (Monthint) <= 12 then
    MonthString = MonthName(MonthInt)
Else
    MonthInt = MonthInt - 12
    MonthString = MonthName(MonthInt)
    YearString = (Year({StaffProjVar;1.Begin date}) + 1)
End If  

Formula = (MonthString + " " + (Cstr(YearString)))
Comment
Watch Question

Éric MoreauSenior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016

Commented:
You can format your object by right-clicking on it, select Format Object, and from the Number tab, select the format without the comma -1123

Author

Commented:
Unfortunately the Formula is returning a string so the number tab is not an option.
I need to fromat it before it is returned.
Éric MoreauSenior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016

Commented:
have you tried:
Formula = (MonthString + " " + replace(Cstr(YearString),',',''))

Author

Commented:
Still didn't work, It seems as though the field is being converted to currency on tyhe yeild function this is CR 2008 maybe it is a bug?
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
You can use the CStr to not insert the ,

CStr(YearString),0,'')

mlmcc
mlmcc's solution will work or you can do a totext(YearString,'0')
Top Expert 2004
Commented:
Mittensonmaui:

You can streamline this formula to one line and get the result you want like this:

formula = cstr(dateadd("m",11,{StaffProjVar;1.Begin date}),"MMMM yyyy")

There is no need to break things down into months and years.  You can just add 11 months to the date, then format it MonthName and Year using the CStr function

Author

Commented:
Great thanks