Solved

MS Access - parsing a string every 3 characters

Posted on 2014-10-01
3
270 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 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Rey Obrero, you were a life saver - thanks!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now