Converting text to numbers (1 Viewer)

exaccess

Registered User.
Local time
Today, 17:12
Joined
Apr 21, 2013
Messages
287
Hi All,
I have been scanning the postings and could find things similar to my problem but not exactly the same issue. Here is the problem. I have a short text field where numbers such as "15.00", "2233.56", "-300.00" are stored. Now I want to convert the text field to numeric so that I have actually 15.00 or -300.00 stored as a double. I am going to do calculations on these fields. How can I achieve this conversion? Help please.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 16:12
Joined
Jul 9, 2003
Messages
16,271
Have you tried changing the field from text to numeretic?
 

exaccess

Registered User.
Local time
Today, 17:12
Joined
Apr 21, 2013
Messages
287
Yes I have tried that. But I am still getting 21.6 instead of 21.60 or 59.8 instead of 59.80. I am probably missing an obvious point but what. Also I have another related question which is giving the final result of the program. I shall export these numbers to a spreadsheet. How can I set the formatting of the cells of the spreadsheet so that I get exactly the display I want.
 

JHB

Have been here a while
Local time
Today, 17:12
Joined
Jun 17, 2012
Messages
7,732
Open the table in design view:
Set the Format to Fixed and Decimal Places to what you want.
 

Attachments

  • FixedNumber.jpg
    FixedNumber.jpg
    21.6 KB · Views: 411

DrPat

Registered User.
Local time
Today, 11:12
Joined
Feb 7, 2011
Messages
39
Hi Exaccess,

This can be a very useful tool as a public function.

I'm at work and don't have time to fiddle with this, but it seems you need to:
1. Find the number of characters after the decimal in your string
2. Coerce the string with CDbl() while setting the format to match the number of decimal places discovered in step 1.

to get you started, I found a public function to find the number of decimal places here.

Good luck,
/Pat
 

Users who are viewing this thread

Top Bottom