Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Aug 2001
    Location
    Kent, England
    Posts
    108
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wildcard as text (Access 2000)

    I have data that resides on a database where the * forms part of a text string.

    How can i get my query to search for the exact string "19830817*001" without access treating the * as a wildcard???

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wildcard as text (Access 2000)

    If you use
    [MyField] Like "19830817*001"
    the * will be treated as wildcard.
    If you use
    [MyField] = "19830817*001"
    the * will be treated as literal
    Francois

  3. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Wildcard as text (Access 2000)

    Hi,
    In addition to Francois answer, if you want to search for a string that contains one of the wildcard characters, you can enclose the wildcard in square brackets:
    e.g. Like "123[*]*" would search for anything which started with "123*".
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  4. #4
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Wildcard as text (Access 2000)

    As an example, a field in your table contain three records as follows:

    19830817*001
    198*5612
    200*25645

    You want a query that will only return the 198*5612. The following statement will do this:
    Like ("198[*]*")
    The * in[*] is treated literally as a character instead of a wildcard.
    Regards,

    Gary
    (It's been a while!)

  5. #5
    2 Star Lounger
    Join Date
    Aug 2001
    Location
    Kent, England
    Posts
    108
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Wildcard as text (Access 2000)

    OK - I've tested the Like (19830817[*]001") and it works perfectly, BUT (there's ALWAYS a but), I couldn't get it to do multiple events.

    For example, I wish to pick up "19830817*001" and "19800923*001"

    Correction - i can get it to do

    Like ("19830817[*]001") Or Like ("19800923[*]001")

    but not using the IN function

    Thanks,
    John

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Wildcard as text (Access 2000)

    Hi,
    The IN operator should work the same way as the equals function - i.e. it will do an exact match so you shouldn't need the square brackets in that situation.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Wildcard as text (Access 2000)

    If the * is always in the same place, the following will work:

    Like ('198?????[*]*')
    Regards,

    Gary
    (It's been a while!)

Posting Permissions

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