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

Count Distinct Access 2000

bhcob1
19
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 8229
NeoPa
32,556 Expert Mod 16PB
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,556 Expert Mod 16PB
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 Expert 8TB
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("*","qryCSOCNumber") 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
Sorry for the misunderstanding, 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,556 Expert Mod 16PB
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
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...
1
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...
17
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...
18
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...
2
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 ...
22
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="...
1
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...
1
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...
7
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.