Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / May 2005

Tip: Looking for answers? Try searching our database.

DCount... I think?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pablo bellissimo - 10 May 2005 09:56 GMT
Sorry for what is probably a simple question but I am having problems.

I have a query which is just returning records that have a 'Location Code'
of STHT.  In each record is an ID number of a person.  Each person can have
multiple records in the query.  I want to add a new column to the query that
counts how many times the ID number (within that record) appears in the
entire query.

I have used the expression builder to do the following but it just counts
the total number of ID numbers in the entire query.

IDCount: DCount("[ID_NO]","[STHT]","[ID_NO]")

I think I somehow need to specify that the criteria only uses the particular
ID number from the record being calculated.

I am very limited with Access so please go easy on me.  This is my last
attempt at trying to make friends with Access after which I will ignore its
existance and just use Excel!!!

Any assistance would be greatly appreciated.

Cheers

Paul
Tom Lake - 10 May 2005 10:17 GMT
> Sorry for what is probably a simple question but I am having problems.
>
[quoted text clipped - 19 lines]
> its
> existance and just use Excel!!!

If ID_NO is a numeric field use this:

IDCount: DCount("[ID_NO]","[STHT]","[ID_NO]=" & [ID_NO])

otherwise use this:

IDCount: DCount("[ID_NO]","[STHT]","[ID_NO]='" & [ID_NO] & "'")

Don't forget the apostrophes in the second example!

Tom Lake
pablo bellissimo - 10 May 2005 13:00 GMT
Tom - thanks for your help.  It does seem to work but is taking forever.  
There are 23k records and 40+ fields.  i will definately use this in the
future though.

Paul

> > Sorry for what is probably a simple question but I am having problems.
> >
[quoted text clipped - 31 lines]
>
> Tom Lake
Justin Hoffman - 10 May 2005 14:32 GMT
> Tom - thanks for your help.  It does seem to work but is taking forever.
> There are 23k records and 40+ fields.  i will definately use this in the
[quoted text clipped - 39 lines]
>>
>> Tom Lake

Although you can use DCOUNT in queries it is, as you have found out, very
slow.  It is OK to show a single count on a form, but for use in queries you
need to use a single SQL statement - which will be much faster.  If you need
help with this, just let us know the table structure you have.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.