Results 1 to 5 of 5
  1. #1
    johnmerlino is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    97

    finding a comma and characters between a space in a field

    Hey all,

    I'm trying to figure out how to find a comma in a field or the characters " TR ", " LIV ", or " REV " (notice the spaces between tr, liv, and rev). Right now I try this and get "syntax error missing operator in query expression".

    SELECT *
    FROM contacts
    WHERE
    (
    contacts.names_1 Like "*" & , & "*"
    Or
    contacts.names_1 Like "*" & TR & "*"
    Or
    contacts.names_1 Like "*" & LIV & "*"
    Or
    contacts.names_1 Like "*" & REV & "*"


    )
    OR
    (
    contacts.names_1 Like "*" & , & "*"
    Or
    contacts.names_1 Like "*" & TR & "*"
    Or
    contacts.names_1 Like "*" & LIV & "*"
    Or
    contacts.names_1 Like "*" & REV & "*"
    )
    )
    ;

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by johnmerlino View Post
    I'm trying to figure out how to find a comma in a field or the characters " TR ", " LIV ", or " REV "
    why not just use INSTR()??

    Code:
    SELECT  *
    FROM contacts
    WHERE  
    
    instr(contacts.names_1, " TR") > 0 OR
    instr(contacts.names_1, " LIV") > 0 OR
    instr(contacts.names_1, " REV") > 0 OR
    instr(contacts.names_1, ", ") > 0

  3. #3
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    Just a small correction to match his description better:

    Quote Originally Posted by ajetrumpet View Post
    Code:
    SELECT  *
    FROM contacts
    WHERE  
     
    instr(contacts.names_1, " TR ") > 0 OR
    instr(contacts.names_1, " LIV ") > 0 OR
    instr(contacts.names_1, " REV ") > 0 OR
    instr(contacts.names_1, ", ") > 0
    Added spaces after TR, LIV & REV

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Quote Originally Posted by johnmerlino View Post
    Hey all,

    I'm trying to figure out how to find a comma in a field or the characters " TR ", " LIV ", or " REV " (notice the spaces between tr, liv, and rev). Right now I try this and get "syntax error missing operator in query expression".

    SELECT *
    FROM contacts
    WHERE
    (
    contacts.names_1 Like "*" & , & "*"
    Or
    contacts.names_1 Like "*" & TR & "*"
    Or
    contacts.names_1 Like "*" & LIV & "*"
    Or
    contacts.names_1 Like "*" & REV & "*"
    )
    OR
    (
    contacts.names_1 Like "*" & , & "*"
    Or
    contacts.names_1 Like "*" & TR & "*"
    Or
    contacts.names_1 Like "*" & LIV & "*"
    Or
    contacts.names_1 Like "*" & REV & "*"
    )
    )
    ;
    Are the red part same as green part?

  5. #5
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    Quote Originally Posted by weekend00 View Post
    Are the red part same as green part?
    Now that you mention it...

    I was so busy looking at the syntax problems that I didn't even notice the redundancy.

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

Similar Threads

  1. Replies: 15
    Last Post: 10-14-2010, 12:22 PM
  2. Replies: 9
    Last Post: 09-23-2010, 10:42 AM
  3. MDB database field limited to 64 or 255 characters
    By galapogos in forum Programming
    Replies: 1
    Last Post: 04-06-2010, 10:22 AM
  4. Counting Characters in a text field
    By velvettiger in forum Queries
    Replies: 1
    Last Post: 03-12-2010, 12:36 PM
  5. Finding highest value in a text field
    By cdominguez in forum Queries
    Replies: 3
    Last Post: 06-02-2009, 09:39 AM

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