599CD.com   Full View
 
 

What's New?  |  Tutorials  |  Tips  |  Blog  |  Forums  |  Help  |  Customer Logon  |  Order

 
     
 
Tips & Tricks
   

  Access   Excel   Word   Windows   FrontPage   Hardware   Misc

 
 

Break Up a Text String in Microsoft Access

Using the InStr Function and String Manipulation

Q: I have an Excel spreadsheet where a single column can sometimes have several different types of data in it. I need to be able to separate those pieces of data out into different fields. How can I do it?

A: Here is the sample data that the customer sent me:

As you can see, the Price field contains all kinds of different bits of data... sometimes a single price like $450,000, sometimes a price per square foot, sometimes a range of prices, and sometimes just "See Agent". We need to be able to break all of these down - and even separate out the minimum and maximum values for those items that give the range of prices so the data looks like this:

How do I do this? Well, the key is to know all of your String Manipulation Functions and to use them properly. In this lesson I needed to use all of these functions:

In addition to:

Here is a video tutorial that shows everything I did, step-by-step, and the sample database that contains all of the query code:

 Click here to view the video
   

 Click here for Sample Database File  ZIP file, 16k, Access 2003 Format

Now, this video goes at a pretty fast clip. It's designed for people who have already taken all of the classes listed above (at least through Access 308). If you have not, then I suggest you take those classes first, and then try to tackle this one!


ADDENDUM (7/24/09): Travis asks: How do I convert this date from 1090621 into 6/21/2009?

Answer: You'll need to learn the string manipulation functions: left, right, mid, from above.

Now, since the first three digits are 109, I'm assuming this was from a legacy (pre-Y2K) database. This is going to make it even more fun. You have to change the way the month and year are calculated based on the length of the whole date. Dates from 1900 to 1999 are 6-digits. Days from 2000 to now are 7 digits.

I would start by breaking this down into different query fields:

MyDay: right(D,2)
MyMonth: IIF(Len(D)=6,mid(D,3,2),mid(D,4,2))
MyYear: IIF(Len(D)=6,left(D,2),left(D,3))
MyYear2: CInt(MyYear) + 1900
NewDate: DateSerial(MyYear2,MyMonth,MyDay)

That last one should be what you're looking for.


 


ADDENDUM (7/25/09): This seems to be a popular topic lately. Here's another one. Scott says he has a table with values that look like this:

He needs to separate out that code - the [a] or [1] - from the rest of the name. Again, our string functions come to the rescue. Here's another video:

 Click here to view the video


 

 

You may want to read these articles from the 599CD Blog:

 

 

Need Help
 
Do you have questions about Word, Excel, Access, Web Design, or computers in general? Just ask us anything you'd like. Click here for assistance.
 

Get Free Tips & Tricks
 

Join our mailing list today and get information on our Free Tips & Tricks Newsletter including free video tutorials, eBooks, live seminars, and more.

Email:
Name:
Type in the word to the left:
 
Your email will be kept 100% safe and will never be given to 3rd parties.

Subscribe to our RSS FeedWhat's This?

Facebook  Twitter  RSS  hide  help

599CD Home   |   Learn More   |   What's New?   |   Contact Us   |   Free Demo   |   FAQs   |   Order Now   |   Affiliate Program   |   TechHelp   |   MYOLP   |   Jobs   |   Downloads   |   Handbooks  (Text)   |    Mailing List   |   Lost Passwords   |   Referral Program   |   Online Poll   |   Corporate, Educational, Government, Non-Profit Sales   |   Message Forums   |   Testimonials   |   Privacy Policy   |   Free Gift CDs   |   Consulting Services   |   Waiting List   |   RSS Feed   |   Tips & Tricks