?
Solved

Data seperation in a field

Posted on 2010-09-17
6
Medium Priority
?
309 Views
Last Modified: 2012-05-10
I have a table with data
in a field that I need
seperated into other fields.
The field with the data is called
FLOC_LABEL.
The data is seperated by a ".",
like ED.RAM.WARN.L131.P161.
The first segment Needs to go
into a field called "Distribution".
The second segment needs to go
into a field called "District".
The third segment needs to go into
a field called Sub_Area.
The fourth segment needs to go
into a field called LineNo.
The fifth segment needs to go
into a field called "Line_Seg".
There are other fields in this
table, so basically I would be
adding the five new fields.
Any help is greatly appreciated.
Thanks


0
Comment
Question by:donnie91910
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 58

Accepted Solution

by:
HainKurt earned 1000 total points
ID: 33703427
create this in modules

Function splitNGet(s As String, n As Integer, seperator As String)
  Arr = Split(s, seperator)
  splitNGet = (Arr(n - 1))
End Function

use

select
splitnget("ED.RAM.WARN.L131.P161.",1,".") as Distribution,
splitnget("ED.RAM.WARN.L131.P161.",2,".") as District,
...
from MyTable
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1000 total points
ID: 33703438
you will need a UDF function to do that

place this codes in a regular Module (not the Form module)

Function SplitField(ByVal idx As Integer, ByVal sValue As String) As String

    Dim infArr() As String
   
    SplitField = ""
    If sValue <> "" Then
        infArr = Split(sValue, ".")
        Select Case idx
            Case 1
                SplitField = infArr(0)
            Case 2
                If UBound(infArr) > 0 Then SplitField = infArr(1)
            Case 3
                If UBound(infArr) > 1 Then SplitField = infArr(2)
            Case 4
                If UBound(infArr) > 2 Then SplitField = infArr(3)
            Case 5
                If UBound(infArr) > 2 Then SplitField = infArr(4)

        End Select
    End If
End Function



to use in a query

select [FLOC_LABEL]
,SplitField(1,[FLOC_LABEL]) as Distribution
,SplitField(2,[FLOC_LABEL]) as District
,SplitField(3,[FLOC_LABEL]) as Sub_Area
,SplitField(4,[FLOC_LABEL]) as LineNo
,SplitField(5,[FLOC_LABEL]) as LineSeq
From NameOftable


you can also use the a query to update the fields in your table
by converting the Select query into an Update query




0
 

Author Closing Comment

by:donnie91910
ID: 33704210
worked great.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…
Suggested Courses

762 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