Solved

MS Access - parsing a string every 3 characters

Posted on 2014-10-01
3
282 Views
Last Modified: 2014-10-01
I'm a fairly novice MS Access user, but I'll bet this is an easy one for most of you.

I have a value in a column that I want to parse into 3 columns. There is no delimiter, but I want every 3 characters...

Source Data:  ABC123xyz987

Goal:
Field1: ABC
Field2: 123
Field3: xyz
Field4: 987

Can you write me a little function for that, please?
0
Comment
Question by:P-Daddy
  • 2
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 40355849
you can do this in a query

select [Source Data],  Left([Source Data], 3) as Field1, Mid([Source Data], 4, 3) as Field2, Mid([Source Data], 7, 3) as Field3, Right([Source Data], 3) as Field4
from TableName
0
 

Author Comment

by:P-Daddy
ID: 40355892
This worked perfectly - thanks!

I had to make one minor tweak to replace the Right with a Mid starting at position 10. Here's my final...

SELECT [qry_1_Assortment_Wide_Open]![CATOP] AS Expr1, Left([qry_1_Assortment_Wide_Open]![CATOP],3) AS 1, Mid([qry_1_Assortment_Wide_Open]![CATOP],4,3) AS 2, Mid([qry_1_Assortment_Wide_Open]![CATOP],7,3) AS 3, Mid([qry_1_Assortment_Wide_Open]![CATOP],10,3) AS 4
FROM qry_1_Assortment_Wide_Open;
0
 

Author Closing Comment

by:P-Daddy
ID: 40355894
Rey Obrero, you were a life saver - thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question