Need some help please. Running Excel VBA, I want to get the number of records in an Access table where the records have a certain value in a field and return that count to Excel. Thanks for any help.
Printable View
Need some help please. Running Excel VBA, I want to get the number of records in an Access table where the records have a certain value in a field and return that count to Excel. Thanks for any help.
Open ado recordset using sql similar to this:
"select count(*) from myTable where myField like '%abc%'"
That should include all records where myField value contain "abc":
khwabclskjdhjsh
abcjdshds
lkjhwgabc
Thanks, but how do I get (display, store) the count itself?
You're not providing enough details for your request so I'm not sure what you mean here...
However, it sounds like you need to add Group By clause to your sql as well. Search our FAQ or db forums or the internet for Group By - you should get plenty of info to get started.
Here is the simple Count/Group By logic:
Code:select
Field1,
COUNT(Field1) As Total1
from Table1
where Field1 like '%abc%'
group by Field1;