ok what have i done wrong???

D

Dave

Hello

I am trying to return a count from a table into a variable. As you can see
from the code below I have the select statement counting the rows where, in
table1, invno is equal to 1. However when i run this code the messagebox is
blank ( i have tried dropping it into a text box but with the same result!).
If I run the Select line as a query though it gives me the correct count as
2. Help!!!

Thanks


Dim rst2 As ADODB.Recordset

Set rst2 = New ADODB.Recordset
With rst2
.ActiveConnection = CurrentProject.Connection
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open ("SELECT count(Table1.invno) as countofno FROM Table1 WHERE
(((Table1.invno) = 1))")
MsgBox (countofno)
End With

rst2.Close
 
R

Rick B

One post please. You don't need three or four different people working on
this in three or four different groups.
 

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

Top