How do I count these?

G

Guest

I have a table, MatchDonors, with two fields: EndwID, DonID. The same EndwID
can have many associated DonID's. I need to set the RowSource of a listbox
to show ONLY those EndwID's with ONE association. The others should not
appear in the list. How do I do that? Can you write some sample code,
because I am really struggling with this. Thanks.
 
G

Guest

In your rowsource create a query showing the MatchDonors table. Add field
EndwID and define a field called OneEndwID: dcount("EndwID","MatchDonors").
Then in your criteria under OneEndwID type =1
 
G

Guest

That method results in a field containing the total of all the records, not a
count of the total for each EndwID.
 
D

Dirk Goldgar

LongWayFromHome said:
I have a table, MatchDonors, with two fields: EndwID, DonID. The
same EndwID can have many associated DonID's. I need to set the
RowSource of a listbox to show ONLY those EndwID's with ONE
association. The others should not appear in the list. How do I do
that? Can you write some sample code, because I am really struggling
with this. Thanks.

I think a query with this SQL should do it, and will be more efficient
than one using DCount() as a criterion:

SELECT EndwID FROM MatchDonors
GROUP BY EndwID
HAVING Count(DonID) = 1;
 
R

Ron2006

make two queries

query 1
group by endwid count
Count Donid


Query 2 which will be used for rowsource of the list box
Select endwid
criteria CountofDonid = 1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top