Jose C
asked on
Separate a Record based on ":"
i have a record field called FULLNAME that looks like the following:
FULLNAME
Category:Division:Manufact urer:PartN umber
however, not all records have a Partnumber indicated since they may be the parent.
an example-
FULLNAME
Sales:Tools:Acme
Sales:Tools:Acme:abc
Sales:Tools:Zenith
Sales:Tools:Zenith:123
I would like a query that will separate them as follows, taking into account that the partnumber field may be blank/null
Category Division Manufacturer PartNumber
Sales Tools Acme null
Sales Tools Acme abc
Sales Tools Zenith null
Sales Tools Zenith 123
I prefer ONE query instead of a separate query to extract each divisor..
help is appreciated.
thanks!
FULLNAME
Category:Division:Manufact
however, not all records have a Partnumber indicated since they may be the parent.
an example-
FULLNAME
Sales:Tools:Acme
Sales:Tools:Acme:abc
Sales:Tools:Zenith
Sales:Tools:Zenith:123
I would like a query that will separate them as follows, taking into account that the partnumber field may be blank/null
Category Division Manufacturer PartNumber
Sales Tools Acme null
Sales Tools Acme abc
Sales Tools Zenith null
Sales Tools Zenith 123
I prefer ONE query instead of a separate query to extract each divisor..
help is appreciated.
thanks!
I use a function:
SELECT fnParse([yourField], 1, ":") as Category,
fnParse([yourField], 2, ":") as Division,
fnParse([yourField], 3, ":") as Manufacturer,
fnParse([yourField], 4, ":") as PartNumber
FROM yourTable
Public Function fnParse(TextToParse As String, Position As Integer, Optional Delimiter As String = " ") As Variant
Dim strArray() As String
strArray = Split(TextToParse, Delimiter)
If Position > UBound(strArray) + 1 OR Position < LBOUND(strArray) + 1 Then
fnParse = NULL
Else
fnParse = strArray(Position - 1)
End If
End Function
Then, in the query, I would do:SELECT fnParse([yourField], 1, ":") as Category,
fnParse([yourField], 2, ":") as Division,
fnParse([yourField], 3, ":") as Manufacturer,
fnParse([yourField], 4, ":") as PartNumber
FROM yourTable
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry for the delay in accepting a solution.
Capricorn's came out the quickest and easiest for keeping it within access.
Capricorn's came out the quickest and easiest for keeping it within access.
copy/ paste this data into Excel
Use the Data-->Text-->To Columns feature to split this data into separate fields.
(Set the delimiter as the colon)
Then copy/paste the resulting Excel data into Access as a new table.