Results 1 to 9 of 9
  1. #1
    shuddle is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    43

    Removing all spaces in an email string


    I have the field Email in the form Fm_Data_Entry where there are spaces that were uploaded with the data. I want to put in some kind of TRIM in the field's Event so that it will correct those that are already in there and any that may be added in the future. I don't know how the script should go. Any help would be appreciated.

  2. #2
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Run a query like this to delete all the spaces in the table:
    Code:
    UPDATE [table name] SET [table name].[email field] = Replace([table name].[email field], " ", "");
    And use the same replace function in your form's before update event to remove spaces the user might enter in the form
    Code:
    Me![email field] = Replace( Me![email field] , " ", "")

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,800
    If you can, the expedient thing to do is remove them as part of the upload process, otherwise they are there until you manually fix it.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    shuddle is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    43
    Those worked great, however I'm still getting some duplicates when I group the emails. Most are combining to one email but there is a hand full that are not. I thought it was because of spaces in the emails but I can't see anything different. Is there a way to weed out duplicate emails rather than grouping them?

    SELECT Tbl_DO_Stakeholder_data.Email
    FROM Tbl_DO_Stakeholder_data
    GROUP BY Tbl_DO_Stakeholder_data.Email;

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,933
    Quote Originally Posted by shuddle View Post
    Those worked great, however I'm still getting some duplicates when I group the emails. Most are combining to one email but there is a hand full that are not. I thought it was because of spaces in the emails but I can't see anything different. Is there a way to weed out duplicate emails rather than grouping them?

    SELECT Tbl_DO_Stakeholder_data.Email
    FROM Tbl_DO_Stakeholder_data
    GROUP BY Tbl_DO_Stakeholder_data.Email;
    Use DISTINCT ?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    shuddle is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    43
    I found the problem. Some of the names have a return (extra line under it). How would I correct this?

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Please show an example of this record with (extra line under it).

  8. #8
    shuddle is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    43
    I'm unable to upload the example due to security on my computer.

    I will just correct them manually in the initial upload. After that it shouldn't be a problem.

    Thank you for your help.

  9. #9
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Code:
    UPDATE [table name] SET [table name].[email field] = Replace([table name].[email field], vbCrLf, "")

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

Similar Threads

  1. Spaces in String
    By DMT Dave in forum Access
    Replies: 16
    Last Post: 10-31-2020, 01:58 PM
  2. Removing Unwanted Spaces From Table Fields, Access 2007
    By rd.prasanna in forum Programming
    Replies: 3
    Last Post: 11-11-2013, 05:23 PM
  3. Removing blank spaces created by LEFT statement
    By Paintballlovr in forum Queries
    Replies: 16
    Last Post: 07-09-2013, 12:19 PM
  4. Replies: 1
    Last Post: 04-16-2013, 07:57 PM
  5. Look Up table with string that contain spaces
    By Leonidsg in forum Database Design
    Replies: 1
    Last Post: 04-03-2013, 06:53 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