Results 1 to 5 of 5
  1. #1
    chronister is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    13

    Query works, but same where condition does not with OpenForm

    Hello all... I am creating a search function to search a name. The DB stores it as [First Name] , [Last Name].... This query works



    Code:
    SELECT *
    FROM tblVolunteers
    WHERE ((([First Name] & " " & [Last Name]) Like "*bob j*"));
    It will show me records for Bob Johnson, Bob James and Bob Jones....

    am trying to duplicate this with a DoCmd.OpenForm statement... can anyone tell me what I am doing wrong? Replacing the static name with a field variable.

    Code:
    Dim whereClause As String
    whereClause = "[First Name]" & " " & "[Last Name] Like " '*" & volunteerName & "'*""
    DoCmd.OpenForm "Volunteers", acNormal, , whereClause, , , False

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Try



    whereClause = "[First Name] & ' ' & [Last Name] Like '*" & volunteerName & "*'"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    chronister is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    13
    Forgot to mention... getting Syntax Error (Missing Operator)..... thanks for the help in advance folks

  4. #4
    chronister is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    13
    U the man.... that fixed it.....

    Thanks a bunch. I am still fairly new to Access in depth. I am still trying to pick up on the syntax and such for creating spaces in fields and concatenating things. I will study that and see exactly what it is that I missed before. thank you sir

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Query works but VBA fails
    By dumbledown in forum Queries
    Replies: 11
    Last Post: 03-16-2012, 10:37 AM
  2. query works but not with command btn
    By Waubain in forum Access
    Replies: 8
    Last Post: 10-24-2011, 10:19 AM
  3. Update Query how it works
    By waqas in forum Queries
    Replies: 10
    Last Post: 09-10-2011, 11:04 AM
  4. Update Query Works Once
    By Lorlai in forum Access
    Replies: 2
    Last Post: 07-22-2011, 08:31 AM
  5. CrossTab query works intermittently
    By mlcohenaz in forum Queries
    Replies: 1
    Last Post: 06-01-2010, 09:23 AM

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