Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Apr 2007
    Location
    Lancashire, United Kingdom
    Posts
    264
    Thanks
    32
    Thanked 5 Times in 5 Posts

    trim in a query (Access 2003)

    I have two lists which I need to compare for differences. But they may each have leading or trailing spaces. Is there anyway to either get rid of them easily or to write a simple differences query which includes the trim function?

    thanks for any help

    Alan

  2. #2
    3 Star Lounger MacroAlan's Avatar
    Join Date
    Feb 2003
    Location
    St Louis, Missouri, USA
    Posts
    254
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: trim in a query (Access 2003)

    Look at the RTrim (right) and LTrim (left) instructions. In your query use RTrim(the_field)
    Alan

  3. #3
    3 Star Lounger
    Join Date
    Apr 2007
    Location
    Lancashire, United Kingdom
    Posts
    264
    Thanks
    32
    Thanked 5 Times in 5 Posts

    Re: trim in a query (Access 2003)

    So where in this SQL query would it go?

    SELECT [All Known Services from the MSL].Service
    FROM [All Known Services from the MSL] LEFT JOIN [Service List from the BUS] ON [All Known Services from the MSL].Service = [Service List from the BUS].[Vodafone Services]
    WHERE ((([Service List from the BUS].[Vodafone Services]) Is Null));

    thanks

    Alan

  4. #4
    3 Star Lounger MacroAlan's Avatar
    Join Date
    Feb 2003
    Location
    St Louis, Missouri, USA
    Posts
    254
    Thanks
    6
    Thanked 1 Time in 1 Post

    Re: trim in a query (Access 2003)

    I don't know which field you are showing me that has trailing blanks. Here is an example that trims training blanks:
    <pre> WHERE ((rTrim$([Service List from the BUS].[Vodafone Services])</pre>

    Alan

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: trim in a query (Access 2003)

    Welcome to Woody's Lounge!

    Try this:

    SELECT [All Known Services from the MSL].Service
    FROM [All Known Services from the MSL] LEFT JOIN [Service List from the BUS] ON Trim([All Known Services from the MSL].Service) = Trim([Service List from the BUS].[Vodafone Services])
    WHERE ((([Service List from the BUS].[Vodafone Services]) Is Null));

    This query cannot be displayed in design view, only in SQL view and in datasheet view, because of the use of Trim in the Join fields.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •