Results 1 to 8 of 8
  1. #1
    SEPIA is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Philadelphia, PA
    Posts
    5

    need query 1: How many characters in a text field? If >4 need to trim or truncate.i

    Novice 1st post: I am trying to support a nonprofit's Access DB. Need advice on how to write criteria to find records in a table with a text field called "MtngType" with more than 4 characters. I will then need to trim or truncate that field in those records.
    Click image for larger version. 

Name:	AccessSnippit.PNG 
Views:	15 
Size:	5.7 KB 
ID:	16910

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

    Actually you'll need to keep a column with MtngType and no criteria to get the field values returned.
    You need a column like your current MtngType but
    Use Len(MtngType) in place of MtngType and no quotes around the 4.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Do you really want to change the data in table? A query can retrieve the first 4 letters without changing the data.

    Left([MtngType],4)

    If you really want to change data, that would be an UPDATE query.

    UPDATE tablename SET MtngType=Left([MtngType],4);
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    SEPIA is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Philadelphia, PA
    Posts
    5
    Thank you Orange for your response. I am trying to determine how many records have more than 4 characters in that field.

  5. #5
    SEPIA is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Philadelphia, PA
    Posts
    5
    Hi June7. I did not make my post clear. I need to know how many and which records contain a character length greater than 4.
    After determining which and how many records and which records are involved I will run the update query.

  6. #6
    SEPIA is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Philadelphia, PA
    Posts
    5
    June7,
    I am not confident that I know how to identify which tables contain the confidential data, nor how to remove the confidential data tables. I do not have the right to release the database.
    Both simple queries as suggested by you and Orange worked to give me records that seem to contain 4 or less characters in the field. I do not know how to modify the left function or the len function to return records with more than 4 characters.
    Thanks

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Orange has given you the method to return records with more than 4 characters. Create a field in query with expression: Len([MtngType])

    And apply filter criteria under that constructed field: >4
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    SEPIA is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Location
    Philadelphia, PA
    Posts
    5
    Thank you both. Problem solved. There were few enough records that a manual update rather than an update query will work for us.

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

Similar Threads

  1. Replies: 1
    Last Post: 05-01-2014, 11:33 AM
  2. Trim first 13 characters, Cut It Out
    By redbull in forum Programming
    Replies: 2
    Last Post: 09-12-2013, 07:19 AM
  3. how to trim text in a column using sql query of ms access
    By learning_graccess in forum Access
    Replies: 4
    Last Post: 12-05-2011, 07:15 AM
  4. Counting Characters in a text field
    By velvettiger in forum Queries
    Replies: 1
    Last Post: 03-12-2010, 12:36 PM
  5. Truncate text
    By jgelpi in forum Programming
    Replies: 3
    Last Post: 07-16-2009, 12:44 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