Results 1 to 5 of 5
  1. #1
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    242

    Count number of records starting with specific characters

    Hi to all,
    I am trying to count number of records in table tblKeyWords with two fields only: (pkKeyWords, KeyWords) starting with three specific alphabets, say wis as an example.

    I have records like:
    Wisdom
    Wise

    I have the following code:
    Code:
    SELECT Left$([keyword],3) AS expr1, Count (KeyWords) AS NumRows FROM  tblKeyWords WHERE [KeyWords] Like "wis*" GROUP BY  Left$([keyword],3);
    Running the query asks for Parameter Value and it takes the first three letters. If I type wiso the result is: wis 12 (meaning that I have 12 records starting with the letters wis)



    Is it possible to replace the (Like "wis*") with the Parameter Value ?
    If I type summary it takes the letters sum as the like part of the criteria.

    Khalil

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    The query as shown wouldn't ask for a parameter?
    If it does you have specified one but aren't using it.

    Try this
    Code:
    SELECT Left$([keyword],3) AS Matches, Count (KeyWords) AS NumRows FROM  tblKeyWords WHERE [KeyWords] Like [Enter Search Letters] & "*" GROUP BY  Left$([keyword],3);
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    242
    Hi,
    Thank you for the reply.
    The query I have do ask for a parameter but I am not able to use that parameter. I want to use the first 3 letters of the parameter I type.
    Thanks.

  4. #4
    Khalil Handal is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jun 2016
    Posts
    242
    Hi,
    I got what I needed with the following code:
    Code:
    SELECT Left$([keyword],3) AS Matches, Count (KeyWords) AS NumRows FROM  tblKeyWords WHERE [KeyWords] Like (Left$([keyword],3)) & "*" GROUP BY  Left$([keyword],3);
    Thank you
    Khalil

  5. #5
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Sorry your use of Keyword as the parameter and Keywords as the field name confused me- I didn't spot the subtle difference in it until your reply.

    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

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

Similar Threads

  1. Replies: 17
    Last Post: 09-12-2020, 01:28 AM
  2. Replies: 8
    Last Post: 05-04-2018, 12:17 AM
  3. Replies: 6
    Last Post: 02-10-2017, 08:21 AM
  4. Count of specific number
    By samirmehta19 in forum Access
    Replies: 3
    Last Post: 05-20-2013, 02:29 PM
  5. Replies: 1
    Last Post: 01-24-2013, 05:50 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