Results 1 to 3 of 3
  1. #1
    desimoreno is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    14

    inserting "dashes" into text field


    Hi, I'm trying to update some fields in Access (2003), but my key link between the two tables came from two separate sources and have been formatted differently. the field is a pole location ID. it consist of three categories. example is 12D3-X1-03. one table uses dashes, while the other table doesn't "12D3X103". I'm going to create a new field called Pole No. I want to populate it with the dashes. can you please show me how to do this? while you're at it, could you also show me how to "remove" the dashes
    thank you in advanced.
    desi
    PS, if you don't mind, I'd really appreciate an email at desim@mid.org

  2. #2
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742

    Mid and &

    The two items you need to know are the substring function (Mid()) and concatenate operator (&). You can also use Left() or Right() to get some substrings.
    http://www.techonthenet.com/access/f...string/mid.php

    Code:
    Dim str1 As string
    Dim str2 As string
    Dim str3 As string
    
    str1 = "12D3X103"
    
    str2 = mid(str1,1,4) & "-" & mid(str1,5,2) & "-" & mid(str1,7,2)
    ' str2 is now 12D3-X1-03
    
    str3 = mid(str2,1,4) & mid(str1,6,2) & "-" & mid(str1,9,2)
    'str3 is now 12D3X103

  3. #3
    desimoreno is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    14
    thank you. . .I also had one emailed to me that also worked, so I Thought I'd share this as well

    insert the dashes. . .
    left([pole_id],4)&”-“&mid([pole_id],5,2)&”-“&right([pole_id],2)

    remove the dashes
    Replace([pole_id]”,”-“,””) - I didn't try this one yet, but I did try the one to insert

    thanks


Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 04-22-2013, 06:08 AM
  2. Replies: 6
    Last Post: 12-28-2012, 02:54 PM
  3. Export "Query or Report" to a "Delimited Text File"
    By hawzmolly in forum Import/Export Data
    Replies: 3
    Last Post: 08-31-2012, 08:00 AM
  4. Problem with inserting "DATE" in reports
    By Larry Fox in forum Access
    Replies: 1
    Last Post: 08-24-2011, 07:09 AM
  5. Replies: 16
    Last Post: 07-22-2011, 09:23 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums