473,395 Members | 1,616 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,395 software developers and data experts.

How to count records of the same individual?

1
Hello,

I am working on a database with the following structure:

ID trait1 trait2
1 899 789
1 600 700
1 500 560
2 430 560
2 600 700
2 800 230
2 500 650
...

So I have multiple measurements per each individual.
I would like to add a column numbering observations for each individual.
I would like it to look like that:

measurement ID trait1 trait2
1 1 899 789
2 1 600 700
3 1 500 560
1 2 430 560
2 2 600 700
3 2 800 230
4 2 500 650
...

Is that possible in Access?
I will be very grateful for your help.
Sep 15 '10 #1
1 1475
liimra
119 100+
Yes it is possible.

First, create another field in your table to number your records. Call it SeqID

SeqID - ID -- trait1 -- trait2
1------- 1 -----899 ----- 789
2------- 1 -----600 ----- 700
3------- 1 -----500 ----- 560
4------- 2 -----430 ----- 560
5------- 2 -----600 ----- 700
6------- 2 -----800 ----- 230
7------- 2------500 ----- 650

Now you create a query that will do what require:

Expand|Select|Wrap|Line Numbers
  1. SELECT TableName.SeqID, TableName.ID, DCount("[ID]","ThisQueryName","[ID] = '" & [ID] & "'")-DCount("[ID]","ThisQueryName","[ID] = '" & [ID] & "' AND [SeqID] > " & [SeqID]) AS RunningCount
  2. FROM TableName
  3. GROUP BY ThisQueryName.SeqID, ThisQueryName.ID
  4. ORDER BY ThisQueryName.SeqID;
Of course, you can add all the fields you want to this query.

Regards,
Ali
Sep 15 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: deko | last post by:
I have a form with a subform datasheet - I need code behind the OnDelete event of the subform: Private Sub Form_Delete(Cancel As Integer) 'do something that depends on which record is deleted...
0
by: Lauren Quantrell | last post by:
I'm using SQL Server backend on an Access 2K front end. I populate a subform: Forms!myForm.myChild.Form.RecordSource = "myStoredProcedureName" On that form is a control where the controlsource is...
4
by: Sjef ten Koppel | last post by:
Hi, I've a small problem. I have a table in which one column is date. I want to count the records for statiscs in a temptable grouped by months lets say 12 months back. e.g. month 1 counts 164...
2
by: Pete | last post by:
I need to create a single query (Not a SQL query) against a single table that counts the number of records in the table, where the single field "tmp" contains specific string values If the field...
1
by: Etayki | last post by:
Hi! I am trying to find the number of records stored in my table within a MS SQL database. This is part of a Console Application. Here is my code: Sub RecordCount() Dim cmd2 As New...
5
by: Soccer5 | last post by:
Trying to Count records on a report that meet a certain criteria. Have a text box in the Report Footer that has the following in the Control Source: =Count(="S") This does not work. It...
6
markrawlingson
by: markrawlingson | last post by:
Hopefully someone can help me out with this, it's driving me nuts... I have two tables - We'll call them table1 and table2. Table1 holds event information, and table2 holds user registration data...
19
by: hotflash | last post by:
Hi CroCrew et. All, I am currently working on a quick report that count a total of completed records per Individual. The code that I have will add up all Individual completed records and what I...
4
by: AccessHunter | last post by:
Hi, I have a table with the type of data as below, sorted as follows, Case (ascending), Loc (ascending) and Transaction Date (ascending). CASE LOC TRANSACTION DATE FACILITY...
5
by: phill86 | last post by:
Hi I want to be able to count records in a dao.querydef recordset but I keep getting the error message method or data member not found I have also tried to find out if the recordset is at...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.