Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2010
    Location
    Perth
    Posts
    6

    Cool Using wildcards (*) in SQL

    In the code below I attempt to use wildcards (*) in a = in SQL for MS Access.


    I want to compare the contents of a textbox with a field in a table and if that field contains the textbox string include the record in the recordset.

    Case 4:

    tempKeywords = Me.txtKeywords

    'tempContactTypeID = Me.cboContactType.Column(0)
    'tempContributionTypeID = Me.cboContributionType.Column(0)

    SQL_1 = "SELECT Contacts.*" _
    & " FROM Contacts INNER JOIN Contribution ON Contacts.ContactID = Contribution.ContactID" _
    & " WHERE Keywords =*" & tempKeywords & "*" _
    & " ORDER BY LastName"

    MsgBox (SQL_1)

    RegenQuery "Test", SQL_1

    End Select


    This code errors.

    Any suggestions to get the following line of SQL to work:

    & " WHERE Keywords =*" & tempKeywords & "*" _


    Thanks,

    Dean.

  2. #2
    dsmacs is offline Advanced Beginner
    Windows XP Access 2010 (version 14.0)
    Join Date
    Oct 2009
    Location
    Perth Western Australia
    Posts
    52
    Change the Where clause to;

    & " WHERE Keywords Like '*" & tempKeywords & "*'" _

    Also add a semicolon ; at the end of the Order By statement

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

Similar Threads

  1. Wildcards?!
    By esx_raptor in forum Access
    Replies: 3
    Last Post: 02-19-2010, 03:22 PM

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