Results 1 to 9 of 9
  1. #1
    TSpeak is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    3

    Locating records with fields that have multiple spaces in the string


    I am pretty new to Access and I am trying to help do some data cleanup within the database. I currently have a few tables that have some pretty old data in it (that we still need) revolving around different organizations (tbl_organizations). The problem I have is that the name field (orgname) has names in it that have more than one space in the name (i.e. - My Garage). I want to run a query on this table that returns all records where the field has more than one space following the first word in the string.

    Any help for this newbie is greatly appreciated.

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    can't you just run an update query on that field and replace any double space with a single space, then you wouldn't have to do this at all?

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    probably should have posted a query to do it:

    Code:
    UPDATE TABLENAME SET TABLENAME.FIELDNAME = Replace([FIELDNAME],"  "," ");
    you likely will have to run it a couple of times to make sure it gets all instances of a double space or you can put in a criteria like:

    Code:
    UPDATE TABLENAME SET TABLENAME.FIELDNAME = Replace([FIELDNAME],"  "," ")
    WHERE (((InStr([FIELDNAME],"  "))>0));

  4. #4
    TSpeak is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    3
    That is what will be done eventually. However, I am not the one to do it. I need to find the records first, submit them for update, and then verify the results are as expected.

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    then just run the select query searching for the double space string instead.

  6. #6
    TSpeak is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    3
    Will that also find any records that have more than two spaces? I want all records with greater than one consecutive space in the string. Thank you for your help.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,960
    Query can find records that have at least 2 sequential spaces but won't fix more than 2.

    How many sequential spaces do you expect to fix - 2, 3, 4, 5...?

    Would have to do repetitive Replace operations until all duplicates eliminated.
    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
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    yes it will just use instr([fieldname], " ") it will find any record with at least one double space somewhere in it's string (a non zero value indicates it's found something a 0 result indicates there are no double spaces)

  9. #9
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    err this is editing my instr statement the stuff between the double quotes should be two spaces, not one.

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

Similar Threads

  1. calc field producing unwanted spaces amidst the final string
    By kattatonic1 in forum Database Design
    Replies: 7
    Last Post: 07-12-2013, 10:32 AM
  2. Look Up table with string that contain spaces
    By Leonidsg in forum Database Design
    Replies: 1
    Last Post: 04-03-2013, 06:53 PM
  3. Help locating a record on click
    By cvclubs in forum Access
    Replies: 5
    Last Post: 10-18-2011, 07:54 PM
  4. Multiple Fields in Criteria - String
    By alsoto in forum Forms
    Replies: 3
    Last Post: 08-24-2011, 12:23 PM
  5. Replies: 1
    Last Post: 12-10-2009, 08:41 PM

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