[AccessD] SQL Gurus - Running count.

Max Wanadoo max.wanadoo at gmail.com
Mon Jun 8 17:06:27 CDT 2009


Interesting.  I will watch out for that.

thanks

Max



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jim Dettman
Sent: 08 June 2009 21:41
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] SQL Gurus - Running count.



  Actually, the main problem is that each time you revisit a row, the
function fires again, so the could keeps incrementing. 

  So for example, if you simply view the output of a query, as you scroll
around, the row numbers will keep changing.

Jim.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Charlotte Foust
Sent: Monday, June 08, 2009 3:50 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] SQL Gurus - Running count.

As I recall, the main problem with that approach was that you have to
remember to initialize glngGetLineCounter to zero each time before you
run the query.  Otherwise, the counts just keep climbing.

Charlotte Foust  

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jim Dettman
Sent: Monday, June 08, 2009 12:39 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] SQL Gurus - Running count.


  BTW, there is a faster method, but it's uses are limited (make tables
and as the basis for a report).  It however is a heck of a lot faster
then the sub-query method

Jim.

Define a column as: 

  RowNum:GetLineCounter([<somefield])

Function:

Global glngGetLineCounter As Long

Function GetLineCounter(varName As Variant) As Long

  glngGetLineCounter = glngGetLineCounter + 1
  GetLineCounter = glngGetLineCounter

End Function 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Max Wanadoo
Sent: Monday, June 08, 2009 3:09 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] SQL Gurus - Running count.

Any takers please?

Max



-----Original Message-----
From: Max Wanadoo [mailto:max.wanadoo at gmail.com]
Sent: 08 June 2009 19:14
To: 'Access Developers discussion and problem solving'
Subject: SQL Gurus - Running count.

Hi Guys,

With a select statement, how do I get a running count matching the rows
return.
Starting at 1 and incrementing by 1 for each row.
The final count to be equal to the number of rows returned.
The count to be part of the query.

I also want a second Count but this time not incremented.  Just a 1 in a
column for each row returned.

Thanks

Max



--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list