Set cnn1 = New ADODB.Connection
Set rs = New ADODB.Recordsetstrcnn = "DSN=MS Access Database;DBQ=" & App.Path & "\mydb.mdb;DefaultDir=" & App.Path & ";FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;PWD=passwd;UID=userid;"
cnn1.Open strcnnrs.Open "select * from table1 where bz='a'", cnn1
leable1.caption=rs.RecordCountrs.Open "select * from table1 where bz='b'", cnn1
leable2.caption=rs.RecordCount

解决方案 »

  1.   

    select count(id) as bbb from table where bz='a' 
    label1.caption=rs!bbb
      

  2.   

    dim numA as integer,numB as integer,numAll as integer
    rs.Open "select count(*) as num from table1 where bz='a'", cnn1
    numA=rs("num")rs.Open "select count(*) as num from table1 where bz='b'", cnn1
    numB.caption=rs("num")numAll=numA+numB
      

  3.   

    rs.open "SELECT COUNT(*) AS CHILD_NUM FROM table1 GROUP BY bz",con,adopendynamic
    i=0
    while not (rs.eof or rs.bof)
            num(i)=rs("child)num")
            i=i+1
    wend
    numall=0
    for i=0 to ubound(num)
       numall=numall+num(i)
    Next
      

  4.   

    sql:select 记录标志,count(*) as countnum from yourtablename
    group by 记录标志
    union all 
    select '合计' as 记录标志,count(*) from yourtablename