A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Convert Text field to Number Field



 
 
Thread Tools Display Modes
  #1  
Old June 5th, 2007, 09:19 PM posted to microsoft.public.access.gettingstarted
davedinger
external usenet poster
 
Posts: 6
Default Convert Text field to Number Field

I have a field that is formated as 123-45-6789 in text format with a field
length of 50. I need to convert it to a number IE: 123456789. I cant get it
to convert because of the "-" is there a way to do this?
  #2  
Old June 5th, 2007, 09:59 PM posted to microsoft.public.access.gettingstarted
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Convert Text field to Number Field

Val(Replace(NameOfField, "-", ""))

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"davedinger" wrote in message
...
I have a field that is formated as 123-45-6789 in text format with a field
length of 50. I need to convert it to a number IE: 123456789. I cant get
it
to convert because of the "-" is there a way to do this?



  #3  
Old June 5th, 2007, 10:26 PM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Convert Text field to Number Field

On Tue, 5 Jun 2007 13:19:03 -0700, davedinger
wrote:

I have a field that is formated as 123-45-6789 in text format with a field
length of 50. I need to convert it to a number IE: 123456789. I cant get it
to convert because of the "-" is there a way to do this?


If this is an identifier (it looks like a Social Security Number by the
format) then I'd say you DON'T want to convert it to a Number datatype. Will
you be doing arithmatic with it?

To keep it as a Text field but just remove the hyphens, run an Update query
updating it to

Replace([fieldname], "-", "")

Also remove any Input Mask on the table field or form control which might be
introducing the punctuation.

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:02 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.