Results 1 to 5 of 5
  1. #1
    shawgrad is offline Novice
    Windows 7 32bit Access 2000
    Join Date
    Feb 2013
    Posts
    3

    Can't seem to put a field name inside a Like command as criteria in a query.


    I have 2 fields in my query, [Last Name] and [Other Names]. I want to select only those records where the [Last Name] of that record is one of the names in the [Other Names] field of that record. I have tried entering as criteria in the [Other Names] field the following: Like "*[Last Name]*" but it brings up records that don't have their Last Name in the Other Names field and also misses some of those records that it should include. I've looked in Access Help, read Access books from the library and searched the internet to no avail. Am I asking the impossible? Please help me if you can.

  2. #2
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    did you try like "*" & [lastname] & "*"
    or
    like "'*" & [lastname] & "*'"

  3. #3
    shawgrad is offline Novice
    Windows 7 32bit Access 2000
    Join Date
    Feb 2013
    Posts
    3
    alcapps,
    Thanks for quick response. Yes, tried both, just rechecked and got "Invalid String" for both. Tried again with " " around [Last Name] and got the same as I had in the past (more records than I should have and some missisng that should have been included) with your 1st suggestion, "*" & "[Last Name]" & "*", and no records at all with your second suggestion, '"*" & "[Last Name] & "*"'. Keep sending ideas, I'll try them all.
    shawgrad

  4. #4
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    can you post your query.. the sql of it?

  5. #5
    shawgrad is offline Novice
    Windows 7 32bit Access 2000
    Join Date
    Feb 2013
    Posts
    3
    Quote Originally Posted by alcapps View Post
    can you post your query.. the sql of it?
    alcapps,
    Here is the SQL view of my query that you ask me to post:

    SELECT Master.[Last Name], Master.[LWH List]
    FROM Master
    WHERE (((Master.[LWH List]) Like "*[Last Name]"));

    I should explain that Master is the name of the table and [LHW List] is the field I referred to as [Other Names] just to make the question more easily understandable. Also, I know that if [Last Name] is one of the names in [LHR List], it is always the last name in the list so I only have an * as a wildcard in the front of the Like expression. If I put one of the last names like Smith in place of [Last Name], it works but than I get only one record and what I want is all the records that have [Last Name] also contained in [LHR List]. Thanks in advance for your help.
    shawgrad

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

Similar Threads

  1. Replies: 4
    Last Post: 10-08-2012, 05:33 PM
  2. Replies: 1
    Last Post: 09-05-2012, 07:04 AM
  3. Replies: 2
    Last Post: 03-22-2012, 01:01 AM
  4. Replies: 1
    Last Post: 08-11-2011, 06:22 AM
  5. Locking a field inside a form
    By cggriggs in forum Forms
    Replies: 2
    Last Post: 06-11-2011, 06:02 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