Results 1 to 3 of 3

Thread: Trim in a Query

  1. #1
    Join Date
    Oct 2002
    Location
    philadelphia
    Posts
    7

    Unanswered: Trim in a Query

    I am relatively a new MS Access 2000 user. I am having a problem with the Trim() string.

    I have created a table with 25 records and it contains 25 fields. I am trying to unite four (4) fields in a query to create one field in a report. I thought Trim() function would work. I have fields that are empty in some records and I don't know how to eliminate those empty fields. (See example)

    Expression: Trim([Field1]&" "&[Field2]&" "&[Field3]&" "&[Field4])

    Results: Store1 Store2 Store4

    Please help, Thanks M.Cobb

  2. #2
    Join Date
    Oct 2001
    Location
    Chicago
    Posts
    440
    IIf(Nz([Field1])="","",[Field1] & " ") & IIf(Nz([Field2])="","",[Field2] & " ") & IIf(Nz([Field3])="","",[Field3] & " ") & IIf(Nz([Field4])="","",[Field4]))

  3. #3
    Join Date
    Feb 2002
    Posts
    2,232
    I agree with Rockey. However, in the future, when you need to use the trim function make sure your trim first then concatenate. So for your example Trim(Field1) & Trim(Field2) & ...

Posting Permissions

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