Results 1 to 2 of 2
  1. #1
    btappan is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Oct 2013
    Posts
    43

    Trim after 50 characters, but also back to last white space.

    I have some fields that need to be trimmed to 20 characters, but I don't want any cut off mid word, is there a way trim down to 20 characters, but also go even further back to the last blank space before the 20th character?

    GREEN BLACK RED GRAY would stay the same


    BLACK RED ORANGE YELLOW would become BLACK RED ORANGE instead of BLACK RED ORANGE YEL

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    In a calculated field (in a Query or on a Report of Form), for a field named "Field3", it might look something like this:
    Code:
    Trim(IIf(Len([Field3])<=20,Left([Field3],20),Left([Field3],InStrRev(Left([Field3],20)," "))))

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

Similar Threads

  1. Remove white space around a Chart object
    By destino in forum Reports
    Replies: 5
    Last Post: 01-29-2021, 10:26 AM
  2. Trim space between fields
    By rbolton in forum Forms
    Replies: 6
    Last Post: 04-14-2014, 08:33 PM
  3. White Space on Report
    By vansicklej in forum Reports
    Replies: 4
    Last Post: 07-31-2012, 12:00 PM
  4. Complicated white space question
    By raytackettsells in forum Access
    Replies: 12
    Last Post: 03-19-2012, 05:14 PM
  5. Remove White Space
    By jsimard in forum Reports
    Replies: 3
    Last Post: 01-24-2012, 12:16 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