Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 5th, 2007, 03:04 PM
Registered User
 
Join Date: Apr 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Running Count Function

I have done some internet research that offeres subqueries as a
solution for my problem, but the efficiency is not good.

I have a table with UNIT_NUMBER, YEAR, PERIOD_PROFILE.

I would like to devlop a user function, to sequentially
count the records with a given unit number and to start the count over
when the unit number changes. This number will help as I need to use a dateadd() function that will utilize the count number calculated by the user function. I want to call this function in a query.


Any help would be great. Here is the hopefuly result


UNIT_NUMBER

UNIT COUNT FUNCTION
0301 1
0301 2
0301 3
0328 1
0328 2
0328 3


 
Old June 7th, 2007, 11:03 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 1 Time in 1 Post
Default

jdbash1,
I have a suggestion or work around to your question.
Try this:

Select COUNT(Unit) + 1 FROM tablename.

OR

SELECT MAX(Unit_Number) + 1
WHERE unit = value
FROM tablename

Hope this helps,
john






Similar Threads
Thread Thread Starter Forum Replies Last Post
Help With Count Function darrenb Access VBA 3 May 2nd, 2007 06:52 PM
Count Function returns strange value tslag XSLT 2 June 23rd, 2006 10:13 AM
is there any in built function to count page count g.tamilselvan MySQL 1 February 15th, 2006 07:43 AM
Count aggregate function Robert_Hill BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 August 24th, 2004 01:12 PM
sql count function - pls help and urgent miki MySQL 1 May 12th, 2004 05:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.