counting

  • Thread starter Thread starter me
  • Start date Start date
M

me

Greetings all from 68° Texas!

I am using a form based upon a query.

record set is approximately 3900+ records, query breaks down to around 314
or so.

I need to extract a record set count from query, assign this to a temporary
variable for a loop.

I do not know how to get a count. I have looked at Dcount but not
appropriate. Am I going about it wrong?

Any help appreciated.

Dave
 
You COULD use DCount, or you could create a Totals query and use the Count
function of SQL. But since you're in code, you could just open the
recordset based on the query, use the MoveLast method to move to the last
record and then use the Count property of recordset variable. Something
like this:

Dim db As Database
Dim rsDyna As DAO.Recordset
Dim LoopVariable as Integer
Set db = CurrentDb

Set rsDyna = db.OpenRecordset("MyQuery", dbOpenDynaset)
rsDyna.MoveLast
LoopVariable = rsDyna.RecordCount

This is DAO code, but similar funtionality exists in ADO.

--
--Roger Carlson
www.rogersaccesslibrary.com
Reply to: Roger dot Carlson at Spectrum-Health dot Org


me said:
Greetings all from 68° Texas!

I am using a form based upon a query.

record set is approximately 3900+ records, query breaks down to around 314
or so.

I need to extract a record set count from query, assign this to a temporary
variable for a loop.

I do not know how to get a count. I have looked at Dcount but not
appropriate. Am I going about it wrong?

Any help appreciated.

Dave




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
Greetings, Dave, from 2° Pennsylvania.

Care to share any of our sunshine?

Steve
PC Datasheet


me said:
Greetings all from 68° Texas!

I am using a form based upon a query.

record set is approximately 3900+ records, query breaks down to around 314
or so.

I need to extract a record set count from query, assign this to a temporary
variable for a loop.

I do not know how to get a count. I have looked at Dcount but not
appropriate. Am I going about it wrong?

Any help appreciated.

Dave





http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
Roger,

You'll have to excuse some of my ignorance here.

The Dim db as database statement-->what is it exactly for?

Dave
 
-----Original Message-----
Greetings all from 68° Texas!

I am using a form based upon a query.

record set is approximately 3900+ records, query breaks down to around 314
or so.

I need to extract a record set count from query, assign this to a temporary
variable for a loop.

I do not know how to get a count. I have looked at Dcount but not
appropriate. Am I going about it wrong?

Any help appreciated.

Dave
Hi Dave,
greetings from New Zealand :-)

Have you tried the .RecordCount property of the form
recordset (in fact of any recordset)?

var = Me.Recordset.RecordCount

Luck
Jonathan
 
It creates a database variable so you can open a recordset. Technically it
is not needed if you change the following line:
Set rsDyna = db.OpenRecordset("MyQuery", dbOpenDynaset)
to this:
Set rsDyna = CurrentDb.OpenRecordset("MyQuery", dbOpenDynaset)
In that case, you wouldn't need:
Set db = CurrentDb
either.

--
--Roger Carlson
www.rogersaccesslibrary.com
Reply to: Roger dot Carlson at Spectrum-Health dot Org

me said:
Roger,

You'll have to excuse some of my ignorance here.

The Dim db as database statement-->what is it exactly for?

Dave






----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
Back
Top