Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text to Columns

Status
Not open for further replies.

TJVFree

Technical User
Nov 22, 2010
236
0
0
US
I have a table in my access database that has fields that I would like to separate like you would in MS excel Text to Columns.
I will need to do this twice a month, if I can automate this step that would be great also

Is there an easy what to do this?

Examples:
12547, Trainer, Chapter, 25

123451, Captain

145875, Coach, Page, Number,
 
Are those values all in a single field? You can use the Split() function to parse out the individual values.

You might want to change your application so you aren't storing multiple values in a single field.


Duane
Hook'D on Access
MS Access MVP
 
Thanks Duane, I've never used the split function. Can you give me an example of what I need to do?

Fieldname: Split([Action Needed])
 
It isn't clear how consistent your data is or isn't. Generically, you can use something like:
Code:
split("a,b,c,d,e",",")(3) = d
split("a,b,c,d,e",",")(0) = a
split(a,b,c,d,e",",")(5) = error generated

Duane
Hook'D on Access
MS Access MVP
 

you may find about Split in your VBA help, or try this code:
Code:
Dim str As String
Dim ary() As String
Dim i As Integer

str = "145875, Coach, Page, Number"

ary = Split(str, ",")

For i = LBound(ary) To UBound(ary)
    Debug.Print Trim(ary(i))
Next i
You get i Immediate Window:
[tt]
145875
Coach
Page
Number
[/tt]

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top