Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordcount on a ADO Recordset 1

Status
Not open for further replies.

zevw

MIS
Jul 3, 2001
697
US
I am trying to get a record count on a ADO recordset and it is not returning anything.

How do I write this?

Code:
Dim adoRS As ADODB.Recordset

Set adoRS = New ADODB.Recordset
With adoRS

    .Open "SELECT CaseNos.* From CaseNos WHERE (((CaseNos.Prog)=" & Val(Forms!CaseForm.OpenArgs) & ") AND ((CaseNos.Year)=" & Year(Forms!CaseForm.CaseDate) & "));"
[COLOR=red]MsgBox adoRS.RecordCount[/color]

End With
 
Perhaps:

Code:
Dim adoRS As ADODB.Recordset

cn = CurrentProject.Connection
Set adoRS = New ADODB.Recordset
With adoRS

    .Open "SELECT * From tblZ", cn, adOpenKeyset
adoRS.MoveLast

MsgBox adoRS.RecordCount

End With
 
Thanks for teaching me!

I guess for record counts I will have to use

Code:
.Open "SELECT * From tblZ", cn, adOpenKeyset

and for adding or editing records I need to use
Code:
.Open "SELECT * From tblZ", cn, adOpenKeyset, adOpenDynamic, adLockOptimistic

Thanks it works
 
You can only have one cursor. They each have different uses, so pick either adOpenKeyset or adOpenDynamic (or some other, as suits). It is generally best to use Access with DAO, unless you have a particular reason for using ADO.
 
Remou,

Where can I learn more about ADO and its functions. I need it here because I am using it for multi user locking see thread705-1357831.

Thanks again for all your help:)
 
Search your local drives for files named ado*.chm

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top