473,569 Members | 2,406 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Count Distinct Access 2000

bhcob1
19 New Member
Hi guys,

I have access 2000, I have a form frmCSOC, with a field [CSOC Number] that can have duplicates, I want a label to display how many records there are with DISTINCT [CSOC Number] values.

I have heard that the DISTINCT keyword does not work on Acc2000.

Thanks Guys
Feb 5 '07 #1
5 8251
NeoPa
32,564 Recognized Expert Moderator MVP
DISTINCT & DISTINCTROW are predicates of the SELECT clause in SQL that work fine in Access 2000 and all subsequent versions.
Feb 5 '07 #2
NeoPa
32,564 Recognized Expert Moderator MVP
Hi guys,

I have access 2000, I have a form frmCSOC, with a field [CSOC Number] that can have duplicates, I want a label to display how many records there are with DISTINCT [CSOC Number] values.

I have heard that the DISTINCT keyword does not work on Acc2000.

Thanks Guys
I can't see how the DISTINCT predicate helps you here mind you.
The best way to get this information on your form is probably to use a DCount() call. You haven't provided information on the table (where the actual data is stored - A form is simply a way of interfacing to a table or set of tables via a query).
Assuming a table called [tblCSOC] with a matching field [CSOC Number] then you need some code in your OnCurrent event procedure :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_OnCurrent()
  2.   lblCount = DCount("[CSOC Number]", _
  3.                     "[tblCSOC]", _
  4.                     "[CSOC Number]=" & Me![CSOC Number])
  5. End Sub
Feb 5 '07 #3
ADezii
8,834 Recognized Expert Expert
Hi guys,

I have access 2000, I have a form frmCSOC, with a field [CSOC Number] that can have duplicates, I want a label to display how many records there are with DISTINCT [CSOC Number] values.

I have heard that the DISTINCT keyword does not work on Acc2000.

Thanks Guys
1__ SELECT DISTINCT tblTest.[CSOC Number] FROM tblTest will return all Unique CSOC Numbers

2__ DCount("*","qry CSOCNumber") where the underlying SQL for qryCSOCNumber is listed above,will return the Total Number of Records containing Unique CSOCNumber values. If I'm not mistaken, this is what you are looking for.
Feb 5 '07 #4
bhcob1
19 New Member
Sorry for the misunderstandin g, my initial post was not very clear.

What I want to do is display the total number of records with a distinct value.

Below is the table tblCSOC, from this table there are 9 records, and 5 distinct [CSOC Number], I would like the label to always display 5, so the user always knows how many CSOCs have been put into the database

Expand|Select|Wrap|Line Numbers
  1. CSOC Number    Issue
  2. 10303                  1
  3. 10303                  2
  4. 10303                  3
  5. 11321                  1
  6. 11321                     2
  7. 12101                  1
  8. 12300                  1
  9. 12301                  1
  10. 12301                     2
Thanks NeoPa
Feb 5 '07 #5
NeoPa
32,564 Recognized Expert Moderator MVP
It looks like ADezii already answered your question for you (twice now but you can't see the deleted post ;))
You could also do it in SQL directly as :
Expand|Select|Wrap|Line Numbers
  1. SELECT Count([CSOC Number])
  2. FROM (SELECT DISTINCT [CSOC Number]
  3.       FROM [tblCSOC])
Feb 5 '07 #6

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

Similar topics

2
3086
by: Paxton | last post by:
Hi, I'm trying to display the total page views per page within a given date range, but the correct SQL is seemingly beyond me. I get the correct result with a straightforward Group By and Count clause eg SELECT DISTINCT tblPageViews.PageVisited, Count(tblPageViews.PageVisited) AS CountOfPageVisited FROM tblPageViews GROUP BY...
1
4168
by: Leny | last post by:
Hi, Since Access doesn't support COUTN DISTINCT, I'm facing a new problem I didn't take into account: how to get the count of PK's in a complex query. I create queries on the fly -this means I can't use a stored macro or even a query view-. A simple example: Let's say you have a simple database with three tables: People, Laguages and a...
17
16357
by: keith | last post by:
I am trying to get a exact count of different distinct entries in an Access column. At first, I was trying to work with three columns, but I've narrowed it down to one to simplify it. I've searched Google Groups for Distinct Count and Count, the Microsoft Help file (which apparently has bad links in Office 2003), and looked at other files,...
18
3041
by: mathilda | last post by:
My boss has been adamant that SELECT DISTINCT is a faster query than SELECT all other factors being equal. I disagree. We are linking an Access front end to a SQL Server back end and normally are only returning one record. She states that with disctinct the query stops as soon as it finds a matching record. Both of us are relative novices...
2
2979
by: pierrelap | last post by:
Hello, I need to code a query that: 1-counts the number of time two companies have been in a deal together 2-in the five years that preceded the deal Lead Participant DealDate AAA BBB 01/01/1990 BBB AAA 01/01/1991 AAA BBB 01/01/1992 AAA BBB 01/01/1993 AAA BBB 01/01/1994
22
12437
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source=" & msDbFilename moConn.Properties("Persist Security Info") = False moConn.ConnectionString = msConnString moConn.CursorLocation = adUseClient...
1
2592
by: Bill | last post by:
I'm trying to write a query that will select a distinct count of more than one field. I have records that display user productivity. Each of the records have a time associated with it and I want to be able to tell the distinct count of the products numbers and of the pallets ID that they worked with. Do need to work out some sort of sub-query...
1
3504
newnewbie
by: newnewbie | last post by:
Desperately need help in creating a query to count unique values in a table. I am a Business analyst with limited knowledge of Access….My boss got me ODBC connection to the underlying tables for our system and thinks I am omnipotent now and can extract any data out of it in the form he wants….The truth is, though I know SOME Access, I am not a...
7
4641
by: CampbellJD1 | last post by:
I am using Access 2003 Professional. I have been working with Access for some time and I have created an MDB with a Linked Table and the Data there is temporarily transferred to other Table for different reports. I now have the task of a Daily report which I have been able to get to the point where it does 90% of what I need. I have been searching...
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.