Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Format Field Post Reply Post New Topic
Page  of 2 Next >>
Author Message
nalfein
Groupie
Groupie


Joined: 07 Jul 2008
Online Status: Offline
Posts: 47
Quote nalfein Replybullet Topic: Format Field
     Posted: 05 Feb 2009 at 6:56am
Hello all

I need to convert a string field in a numer field

Is that possible?

Thank you in advance for answers
IP IP Logged
mudcat1
Newbie
Newbie
Avatar

Joined: 21 Jul 2008
Online Status: Offline
Posts: 11
Quote mudcat1 Replybullet Posted: 05 Feb 2009 at 8:08am
Try it as a formual field using
(toNumber ({Tablename.fieldname})
it should return a number value of the string.
 
You might also want to start the formiual by verifying that the string is a valid number using NumericText ({Tablename.fieldname})  to evaluate if the table value can be converted with toNumber.
IP IP Logged
nalfein
Groupie
Groupie


Joined: 07 Jul 2008
Online Status: Offline
Posts: 47
Quote nalfein Replybullet Posted: 05 Feb 2009 at 8:31am
Ok thank you but another step now hehe

In the fild i have this formula

(toNumber ("0"+Cstr({tablename.fieldname})))

The tablename.fieldname is a number like 1234

I've put cstr command because i need to put a 0 before him so he can be seen on print like 01234
I dont know why the Cstr command transform a field number in a string field but with toNumber i can transform back to number

The problem is that now the field reconverted to number suppress the initial 0 that i've put with the Cstr command

There's a way to see that 0?

Thank you by now
IP IP Logged
mudcat1
Newbie
Newbie
Avatar

Joined: 21 Jul 2008
Online Status: Offline
Posts: 11
Quote mudcat1 Replybullet Posted: 05 Feb 2009 at 8:37am
After the formula is placed on the report, rightclikc ad select format field.  When the format editor opens select number and check "Leading 0"
IP IP Logged
nalfein
Groupie
Groupie


Joined: 07 Jul 2008
Online Status: Offline
Posts: 47
Quote nalfein Replybullet Posted: 05 Feb 2009 at 11:19pm
Not working, i've tryed

But i've found the solution by checking display current symbol and put the 0 instead of money symbol (this solution had not worked until yesterdary and i've tried many many times )

Thank you for answers
IP IP Logged
nalfein
Groupie
Groupie


Joined: 07 Jul 2008
Online Status: Offline
Posts: 47
Quote nalfein Replybullet Posted: 06 Feb 2009 at 1:16am
I've said that was ok but i was wrong

When i print the page the format is

0   1234 (with a unknow space between 0 and the rest of the number)

Any idea? I've really tryed all what i know

Thank you by now for answers
IP IP Logged
nalfein
Groupie
Groupie


Joined: 07 Jul 2008
Online Status: Offline
Posts: 47
Quote nalfein Replybullet Posted: 06 Feb 2009 at 2:57am
Half way to solution maybe

with

cstr ("0"+(totext({@tablename_fieldname},0)))

From a field 12345 i can obtani 012.345

How can i suppress the "."?

Best regards
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 06 Feb 2009 at 3:27am
Hi
 
Why not try the below code see if it works

"0"+Cstr ({Table.fieldname},0)
 
Cheers
Rahul

IP IP Logged
nalfein
Groupie
Groupie


Joined: 07 Jul 2008
Online Status: Offline
Posts: 47
Quote nalfein Replybullet Posted: 06 Feb 2009 at 5:04am
Originally posted by rahulwalawalkar

Hi
 

Why not try the below code see if it works

"0"+Cstr ({Table.fieldname},0)

 

Cheers

Rahul


Same result the 1235 become 012.345 but the "." is still there

IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 06 Feb 2009 at 6:49am
can you mail me the report
 
 
cheers
Rahul
IP IP Logged
Page  of 2 Next >>
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum