2 days ago: New Feature: you can now upload your Profile Picture to the site. Check it out!  Dismiss
 
Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Tips & Tricks

New Tips Added Weekly!
Click here to get on our Mailing List

   
 

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


 


By Richard Rost   Richard Rost on LinkedIn Email Richard Rost
Click here to sign up for more FREE tips

 

 

 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 3/19/2024 7:55:13 AM. PLT: 0s