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 / Macros / November 2006

Tip: Looking for answers? Try searching our database.

Truncate the first 2 characters contained in all cells within 1 column of a table in access

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jsun1973@hotmail.com - 27 Nov 2006 21:51 GMT
I hope the title is descriptive enough.

My problem is as follows:

I am trying to truncate the first two characters from all cells
contained in a specific row within a table in an Access DB.  All
information within this column (from top down) contain information that
looks like:  A-1002-G-0061.  I am looking to truncate all the "A-"
parts.  The first two characters within the cells range from "A-" to
"E-" (i.e. B-1002-G-0061, C-1002-G-0061, etc.)

I looked into the Replace function, but I can't figure out what they
mean by "Expression as string".  I am thinking that I need to link this
to my table, but after a couple of hours of trying to figure out how
that is done, I am about crazy...

Any help on this will be appreciated.

Thanks in advance!
MBSNewbie - 27 Nov 2006 23:32 GMT
I would add a column, then use an update query
The Update query would update the new column{New} with the Truncated {Old}
value

the sql view would look like:

UPDATE Table1 SET Table1.new = Right([Old],Len([Old])-2);

Table1 = Table
Old = Original Column
New = New Column

If you didn't want to add a column, it will work the same:
UPDATE Table1 SET Table1.Old = Right([Old],Len([Old])-2);

>I hope the title is descriptive enough.
>
[quoted text clipped - 15 lines]
>
> Thanks in advance!
Tom Lake - 28 Nov 2006 01:16 GMT
>I would add a column, then use an update query
> The Update query would update the new column{New} with the Truncated {Old}
[quoted text clipped - 3 lines]
>
> UPDATE Table1 SET Table1.new = Right([Old],Len([Old])-2);

or perhaps faster:

UPDATE Table1 SET Table1.new = Mid([Old], 3);

Tom Lake
jsun1973@hotmail.com - 28 Nov 2006 13:44 GMT
> I would add a column, then use an update query
> The Update query would update the new column{New} with the Truncated {Old}
[quoted text clipped - 10 lines]
> If you didn't want to add a column, it will work the same:
> UPDATE Table1 SET Table1.Old = Right([Old],Len([Old])-2);

Your second suggestion worked perfectly.  Thanks so much for bringing
me back from the edge of insanity!  :D
 
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.