Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / March 2006

Tip: Looking for answers? Try searching our database.

Convert Text to Numbers - Leading 0s

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
biztree - 29 Mar 2006 17:22 GMT
I have a column that has Account Numbers with Leading 0s. It is currently a
"Text" field. I want to convert it into a "Number" filed. When I do that by
changing the data type I lose the Account Numbers. Is there a workaround?

PS: I need to link this filed to another table that has the Account Numbers
as a "Numbers" field. Currently the link will not work.
mscertified - 29 Mar 2006 17:26 GMT
Insert a new column for the numbers, then run a query to transfer the text
column to the numbers column, then delete the text column.
Query:
UPDATE MyTable SET MyNumber = CInt(MyText)

Back up your database FIRST!!!

-Dorian

> I have a column that has Account Numbers with Leading 0s. It is currently a
> "Text" field. I want to convert it into a "Number" filed. When I do that by
> changing the data type I lose the Account Numbers. Is there a workaround?
>
> PS: I need to link this filed to another table that has the Account Numbers
> as a "Numbers" field. Currently the link will not work.
John Spencer - 29 Mar 2006 18:46 GMT
Numbers NEVER have leading zeroes.  So, you can add an additional field to
hold the numeric value - probably a bad idea.  Why is this a bad idea, now
you have two fields to maintain the same data.

Better - use the Val function to return the numeric value.  You can do that
in a query of your table and then use that to query and link it to the other
table.

Field: JustNumber: Val([AccountNumber])

Alternative solution is to use a Non-equi Join to do this.  This type of
join needs to be done in SQL view and cannot be built or shown in the query
grid.  Generically, that would look something like the following

SELECT  [TableWithText].[AccountNumber]
, [TableWithNumbers].[SomeOtherField]
FROM [TableWithText] INNER JOIN [TableWithNumbers]
ON Val([TableWithText].[AccountNumber]) =
[TableWithNumbers].[AccountNumber]

>I have a column that has Account Numbers with Leading 0s. It is currently a
> "Text" field. I want to convert it into a "Number" filed. When I do that
[quoted text clipped - 4 lines]
> Numbers
> as a "Numbers" field. Currently the link will not work.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.