Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 15th, 2005, 03:02 PM
Registered User
Join Date: Apr 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Count, sum, count a value, return records

I am trying to count the number of times the same name
occurs in five different fields.

I want to sum the counts of fields 2 - 5,[Other1, Other2, etc.]
and display them in a report side by side with the sum
of the occurences of each name in the first field [LeadName].

The Name fields actually contain a number ("Long Interger")
that is related to an ID number in another "look-up"

A problem I am having:

1) The LeadName qry/qryctab/rpt works fine - all names in the list
display with their associated count sums sorted by month.

    Oct Nov Dec TotalLead
Smith 1 2 3
Jones 1 4 5

However, when I try to add Other1, which also sorts and
displays correctly as a stand-alone, I find it has a different
number of names because not all names had values in the "other"
fields. When I join "Other1" query with the "LeadName" query, only
names with matching name values are returned. ex: QryLeadName number of records is 33, QryOther1 number of records is 5. When I try to make a multiple value field query, only 5 records (those appearing in both QryOther1 and QryLeadName) are returned.

How do I display all the names in the Name list - even thoses with
no records? There are no "null" or "zero-strings" in any fields.

ex: Other1 = 31 ("none" in look-up table).

Ideally, I would like to just have a single sum for fields 2 - 5

AprilTrip LeadName = 12 "Smith" Other1= 13 Other2=14 "Brown"
AprilTrip LeadName = 13 "Jones" Other = 12 Other2=31 "none"

    Smith 1/1 (Trip as lead = 1, Trip as Other = 1
    Jones 1/zero or blank (Trip as lead = 1, Trip as Other = 0

Right now "Jones" has no return because she has no associated record in the "Other" query. I'm getting so confused!

Old April 18th, 2005, 02:25 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG

In your query, you have probably joined the primary key of one table to the foreign key of the other. In design view, double-click the line joining them (take good aim; it's hard to hit) and select the join type you'd like. You probably want the second of three, but read your choices carefully.

Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum and Count - Please Help deepsea007 XSLT 9 June 21st, 2007 02:46 PM
Using count or sum to validate radiobutton rdove84 SQL Server ASP 0 November 8th, 2006 04:17 PM
How to get "SELECT COUNT(*)" return information? datagram ASP.NET 1.0 and 1.1 Basics 3 December 23rd, 2004 01:21 AM
sql to return distinct count pbgurl Access VBA 2 October 29th, 2004 06:29 AM
return record count by quarter jtyson SQL Server 2000 1 June 29th, 2004 11:24 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.