How can I find the count of fields in vba?

  • Thread starter Thread starter hanski
  • Start date Start date
H

hanski

Hi.

I have this:

Dim conn As New ADODB.Connection
Dim str1 As New ADODB.Recordset

Set conn = CurrentProject.Connection

str1.Open "select count(Field1) as Allfields from dbase group by
Field1", conn, adOpenDynamic, adLockOptimistic


I have in my dbase 450 data in Field1. 200 of them are different kind
of, so I thougt that my Allfields result should be 200, but it is
allways 1 !

Why does it find only 1? If I take the "group by field1" away, then
Allfields is 450!!

What is wrong?

hannu
 
Hi Hannu,

SELECT Count(Field1) AS NumUniqueValues
FROM tablename
WHERE (Field1 In (select distinct [Field1] from tablename));


Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top