Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


How to add multiple delimiters to an MS Access field

How to add multiple delimiters to an MS Access field

How to add multiple delimiters to an MS Access field

Being in the travel business I have a field in a database that contains the trip itinerary showing the city codes all run together ... like JFKMIALAXSEA!

I need to still show one field but now need to separate each individual city code, which is 3 characters and enter a dash between them .... JFK-MIA-LAX-SEA!

I can get this to somehow work by using the left and mid function ...
Routing: Left([ITINERARY],3) & "-" & Mid([ITINERARY],4,3) & "-" & Mid([ITINERARY],7,3) & "-" & Mid([ITINERARY],10,3) & "-" & Mid([ITINERARY],13,3) & "-" & Mid([ITINERARY],16,3) & "-" & Mid([ITINERARY],19,3) & "-" & Mid([ITINERARY],22,3) & "-" & Mid([ITINERARY],25,3) & "-" & Mid([ITINERARY],28,3)

BUT /// I never know how many 3 letter city codes are run together as each trip is different. The problem is how to "not" show the extra dashes at the end of my new field by applying the above code!

Any suggestions would be most helpful


RE: How to add multiple delimiters to an MS Access field

CODE -->

Public Function SplitCities(Cities As Variant) As String
  Dim i As Integer
  If Not IsNull(Cities) Then
    For i = 1 To Len(Cities)
       SplitCities = SplitCities & Mid(Cities, i, 1)
       If i Mod 3 = 0 And i <> Len(Cities) Then SplitCities = SplitCities & "-"
    Next i
  End If
End Function 


RE: How to add multiple delimiters to an MS Access field

This solution works like a charm and thus eliminates all of the trailing dashes from my new Routing field.

Can't thank you enough! Most appreciated!


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close