Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert text string to number in a query

9,216 views
Skip to first unread message

twalsh

unread,
Apr 7, 2008, 3:37:01 PM4/7/08
to
Ok i have an infopath form where users enter a number and it is stored into
an access database...
Problem is, Infopath throws a fit if you format those fields as numbers in
access.
I want to run a query that converts the text from the field into a number,
this is because the query will be used in a 'sendobject' macro that will
email data in an excel spreadsheet and the recipients need to be able to
manipulate and calculate with the data, which they can't do if it is sent as
text.
I tried using the expression "Int" as in Int([billable hours]), but it only
brought me the integer, the data thats entered is more like 7.69, 'int'
brought back 7, albeit it was in number format.
Am i on the right path or totally lost?
Please keep in mind i am a bit of a novice here....

Jeff Boyce

unread,
Apr 7, 2008, 4:21:46 PM4/7/08
to
Perhaps there are a couple steps here.

One would be to convert text to number ... a query that uses the CInt() (or
CCur(), or CLng(), or ...) "conversion" function might help.

Then, the issue of formatting for display. Formatting as an integer (short
or long) will only display "whole numbers" (the definition of integer). If
you need up to four decimal places (but no more), the currency data type
does that accurately. If you'll need more than four places, take a look at
single, double and decimal data types and formatting.

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP

"twalsh" <twa...@discussions.microsoft.com> wrote in message
news:D7BE1A60-2267-488C...@microsoft.com...

strive4peace

unread,
Apr 7, 2008, 4:26:29 PM4/7/08
to
try converting to a Single precision or Double precision number

CDbl([billable hours])

"need to be able to manipulate and calculate with the data, which they
can't do if it is sent as text."

Even though it is text in Access, I think you may find that Excel will
treat it as a number without doing anything special...

Warm Regards,
Crystal

*
(: have an awesome day :)
*

raskew via AccessMonster.com

unread,
Apr 7, 2008, 5:43:33 PM4/7/08
to
Hi -

Use the Val() function to convert a string to a number, e.g. from the Debug
(immediate) window:

x = "34.3"
? val(x)
34.3

To show that val(x)is a number
? cdbl(val(x))
34.3

HTH - Bob

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200804/1

twalsh

unread,
Apr 8, 2008, 11:45:00 AM4/8/08
to
This seems to be progress, it is converting to number, however it is
rounding. Ex:

when Billable Hours= 8.40

CDbl(Val([Billable Hours])) returns 8.00

and Val([Billable Hours]) also returns 8.00

raskew via AccessMonster.com

unread,
Apr 8, 2008, 4:50:10 PM4/8/08
to
Hi -

Keep in mind that BillableHours is a string, Example:

BillableHours= "8.40"
? val(billablehours)
8.4
? CDbl(Val(BillableHours))
8.4

Bob

twalsh wrote:
>This seems to be progress, it im is converting to number, however it is

>rounding. Ex:
>
>when Billable Hours= 8.40
>
>CDbl(Val([Billable Hours])) returns 8.00
>
>and Val([Billable Hours]) also returns 8.00
>

>> Hi -
>>
>[quoted text clipped - 25 lines]

0 new messages