UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Extracting Text From A Text String Using Left Function?, Any Version    
 
   
likajoho
post Apr 15 2017, 09:15 AM
Post#1



Posts: 1,071
Joined: 18-February 04
From: Oklahoma


I want to extract text from a string deleting the first 3 characters. I think I can use the Left function in combination with some other function to remove those left 3 characters. So far the how has eluded me. I tried a simple -, but that didn't work.

Thank you for reading my post and for any suggestions.
Go to the top of the page
 
Doug Steele
post Apr 15 2017, 09:20 AM
Post#2


UtterAccess VIP
Posts: 21,856
Joined: 8-January 07
From: St. Catharines, ON (Canada)


From your description, it sounds as though you want to return all but the first three characters. In other words, if the string is UtterAccess, you want to return erAccess.

If that's the case, you want to use the Mid function, not the Left function:
CODE
  strNewString = Mid(strOldString, 4)

(the third parameter for the Mid function, length of string, is optional if you want everything after the start position you've given)

--------------------
Doug Steele, Microsoft Access MVP (2000-2018)
http://www.accessmvp.com/DJSteele/AccessIndex.html
Co-author: Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs, published by Wiley
Co-author: Effective SQL: 61 Specific Ways to Write Better SQL, published by Addison-Wesley Professional
Technical Editor: Access 2010 Bible, Access 2013 Bible, Access 2016 Bible, all published by Wiley
Technical Editor: SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, 4th Edition, published by Addison-Wesley Professional
Go to the top of the page
 
likajoho
post Apr 15 2017, 10:19 AM
Post#3



Posts: 1,071
Joined: 18-February 04
From: Oklahoma


Great! I didn't realize the length was optional and that was where my difficulties were.

Thanks!
Go to the top of the page
 
Doug Steele
post Apr 15 2017, 11:49 AM
Post#4


UtterAccess VIP
Posts: 21,856
Joined: 8-January 07
From: St. Catharines, ON (Canada)


If the length was mandatory, you could use

CODE
    strNewString = Mid(strOldString, 4, Len(strOldString) - 3)

--------------------
Doug Steele, Microsoft Access MVP (2000-2018)
http://www.accessmvp.com/DJSteele/AccessIndex.html
Co-author: Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs, published by Wiley
Co-author: Effective SQL: 61 Specific Ways to Write Better SQL, published by Addison-Wesley Professional
Technical Editor: Access 2010 Bible, Access 2013 Bible, Access 2016 Bible, all published by Wiley
Technical Editor: SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, 4th Edition, published by Addison-Wesley Professional
Go to the top of the page
 
likajoho
post Apr 15 2017, 04:57 PM
Post#5



Posts: 1,071
Joined: 18-February 04
From: Oklahoma


Thanks Doug
Go to the top of the page
 
slacka
post Dec 10 2017, 02:23 AM
Post#6



Posts: 13
Joined: 2-December 17



I do this sometimes but mid is cleaner.

CODE
right(len(string) - 3)
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    19th August 2018 - 05:48 PM