473,386 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Record counter in Access

Sam
Is there a formula or easy way to add a record counter in Access to a
query?

I have a field that contains a file number this file. I want to add a
counter like below.
Field Name Field Name (B)
FileNumber ElCounter
9565845 1
9565845 2

9552456 1
9552456 2
9552456 3
5695695 1
5695695 2
5695695 3
5695695 4
5695695 5
Thanks for your assistance.
Sam
Oct 2 '08 #1
2 9889

"Sam" <sa********@comcast.netwrote in message
news:e4**********************************@p49g2000 hsd.googlegroups.com...
Is there a formula or easy way to add a record counter in Access to a
query?

I have a field that contains a file number this file. I want to add a
counter like below.
Field Name Field Name (B)
FileNumber ElCounter
9565845 1
9565845 2

9552456 1
9552456 2
9552456 3
5695695 1
5695695 2
5695695 3
5695695 4
5695695 5
Thanks for your assistance.
Sam
Try a public function that counts up and resets to 0 when the FileNumber
changes.
You may need to call CountUp(Null) before opening your query

ELCount: CountUp([FileNumber])

Un-tested Code

Public Function CountUp(FileNumber as variant) as Integer
Static iCount as Integer
Static LastFileNumber as variant

if LastFileNumber <FileNumber then
iCount = 0
LastFileNumber = FileNumber
endif
iCount = iCount + 1
CountUp = iCount
EndFunction
Oct 2 '08 #2
Sam wrote:
Is there a formula or easy way to add a record counter in Access to a
query?

I have a field that contains a file number this file. I want to add a
counter like below.
Field Name Field Name (B)
FileNumber ElCounter
9565845 1
9565845 2

9552456 1
9552456 2
9552456 3
5695695 1
5695695 2
5695695 3
5695695 4
5695695 5
Thanks for your assistance.
Sam
Well, if you had an autonumber it would be easy to do.
Dcount("*","TableName","AutoNumFldName < " & [AutoNumFldName] & _
" And FileNumber = " & [FileNumber]) + 1

Oct 2 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: David | last post by:
Hi, I have a .asp page which lists a date, then a bunch of record lines for data that falls within that date, then the next date and it's bunch of data record lines. e.g. Ship Date:...
1
by: SuffrinMick | last post by:
Hi All I have two tables: tblRecords and tblOptions. tblRecords consists of RecordID (autonumber), Record (text) and Option (text record of options chosen) fields tbloptions consists of...
4
by: Paul | last post by:
Hello Everybody, Being new to VBA for Access, I have a question about inputing a text file into access. The text file has 23 lines per file and needs to go into 1 record in a table. The 1st...
4
by: Noah | last post by:
Hi, I bet the question below has been answered many times before, but I have not found an answer. If someone could point me to one that would be great! I have the following table: num ...
2
by: starman | last post by:
I have a form with a subform in it. The subform is based on a query that shows all records and fields (so the user can see what they have already entered). When I look at the form in form view,...
7
by: hjohnson | last post by:
Within the access environment, I have a table that I'd like to -add a column -place the record number of each record into that column The autonumber is not working for me because I am...
6
by: ineedahelp | last post by:
Hi, I am trying to evaluate data in a table. First I need to evaluate NotionalValue for Symbols that match. If it passes my parameters, I need to apply my "flags" to the flag field. Instead of...
6
by: Lee Sander | last post by:
Dear all, I would like to read a really huge file that looks like this: line_11 line_12 line_13 .... line_21 line_22 ....
6
by: Neekos | last post by:
ok i have the following snippet of code. All i want it to do is move to the next record, but i keep getting an error of: You cannot go to the specified record. amount = DCount("*", "") counter =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.