Results 1 to 7 of 7
  1. #1
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85

    Truncate data

    Hello, I have a table with a field that begins with '123 - ' with additional data to the right with different lengths. I need to remove the '123 - ' from the beginning of the field and leave the rest of the data.
    Can I accomplish this using an update query?


    Thanks

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Do all your entries start like this?
    If so, you should be able to use the MID function in your Update statements to get whay you want, i.e.
    Code:
    =MID([FieldName],7,LEN([FieldName])-6)
    If only some start that way, you can use:
    Code:
    Like "123 - *"
    in your criteria to just apply it to those records.

  3. #3
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    if you want to target specific string data only, especially data that is consistent, regardless of it's position, use REPLACE(). that way you don't risk miscalculating byte positions with the arguments of functions like mid().

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I believe the question specified values that begin with "123 - ".
    Won't REPLACE (without using anything else, i.e. criteria) replace it wherever it finds it in the string?
    So if it occurs in the middle or at the end, it would incorrectly remove it, right?

  5. #5
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85

    Truncate Data

    Joe, all of my data begins with "3 numbers a space - space" (6 charac) I am wanting to remove that information and leave all the data to the right.
    so if my field name is 'Spec' would I write the code as follows:
    =MID ([Spec],7,LEN([Spec])-6)

    What does the 7 represent?
    Does the -6 represent the 6 charac I am deleting?
    Thanks.

    ************************************************** ************************************************** ****

    Quote Originally Posted by JoeM View Post
    Do all your entries start like this?
    If so, you should be able to use the MID function in your Update statements to get whay you want, i.e.
    Code:
    =MID([FieldName],7,LEN([FieldName])-6)
    If only some start that way, you can use:
    Code:
    Like "123 - *"
    in your criteria to just apply it to those records.

  6. #6
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    This explanation of the MID function should answer your questions: http://www.techonthenet.com/access/f...string/mid.php

  7. #7
    DCV0204 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    85

    Truncate data

    Problem solved.
    Thanks.

    Quote Originally Posted by JoeM View Post
    This explanation of the MID function should answer your questions: http://www.techonthenet.com/access/f...string/mid.php

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

Similar Threads

  1. Replies: 5
    Last Post: 08-12-2013, 12:53 AM
  2. Replies: 5
    Last Post: 05-14-2012, 02:01 PM
  3. Replies: 1
    Last Post: 12-21-2011, 02:11 PM
  4. Truncate text
    By jgelpi in forum Programming
    Replies: 3
    Last Post: 07-16-2009, 12:44 PM
  5. truncate (?) values
    By ridgeview80 in forum Access
    Replies: 3
    Last Post: 06-02-2009, 02:19 PM

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