Page 1 of 2 12 LastLast
Results 1 to 15 of 27
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    Making everything appear

    I'm making a query that takes care of contacts with all races. I have a table [tblRaceList]. I have all races that we're going to use listed. When a contact is made, I need to keep track of it. I need all the information of each race even if no contact was made. I tried using a left join and a right join. Neither worked. Any advice?


    Click image for larger version. 

Name:	query1.jpg 
Views:	18 
Size:	107.1 KB 
ID:	31973
    Click image for larger version. 

Name:	query2.jpg 
Views:	18 
Size:	70.0 KB 
ID:	31974
    Click image for larger version. 

Name:	query3.jpg 
Views:	18 
Size:	60.4 KB 
ID:	31975

  2. #2
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    You can't count by RaceID / group by race as those fields will be null if no contact made.
    Instead
    1. Add Nz expression to the Race field e.g. ContactRace: Nz(Race,"unknown") and group by that
    2. Count the field PublicContactID
    3. I don't think you need Abs in your two Sum fields as I assume both fields are numbers and will never be negative

    If that still doesn't work, a two step approach may be needed
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    I suspect the two fields being summed are Yes/No type.

    1. Remove tblRaceList from the query.
    2. Building another query that joins filtered aggregate query to tblRaceList. If you want the null fields populated, can use Nz() function, like:

    SELECT Nz([CampusID], Forms!frmTier1DataSearch!cboCampusID) AS CID, Nz([ChkYear], Forms!frmTier1DataSearch!txtYear) AS CY, Nz([CountOfRace],0) AS COR, Searches, CustodyArrests, tblRaceList.Race
    FROM tblRaceList LEFT JOIN Query1 ON tblRaceList.RaceID = Query1.Race;
    Last edited by June7; 01-07-2018 at 06:03 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I put up the wrong query. It was a long night. Here is the correct query.
    Click image for larger version. 

Name:	query1.jpg 
Views:	17 
Size:	106.4 KB 
ID:	31979

  5. #5
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Ridders52,
    I tried putting Nz([Race],"unknown"). It still didn't do what I wanted. I did change it to count [PublicContactID]. That will work much better. Not sure what I was thinking to count the [RaceID].

  6. #6
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Post your query in SQL view or post the relevant parts of your db After removing any confidential data
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  7. #7
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    June7,
    Sorry, I didn't understand what you were trying to tell me. What is Query1?

  8. #8
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    June7,
    Sorry, I didn't understand what you were trying to tell me. What is Query1?

  9. #9
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    In SQL:
    SELECT tblRaceList.Race, tblPublicContact.CampusID, Year([ContactDate]) AS ChkYear, tblPublicContact.PublicContactID, IIf([SearchConducted],1,0) AS Search, IIf([ReasonForSearchID]=1,1,0) AS Consent, IIf([ReasonForSearchID]=3,1,0) AS PC, IIf([ArrestMade],1,0) AS Arrest
    FROM tblPublicContact LEFT JOIN tblRaceList ON tblPublicContact.RaceID = tblRaceList.RaceID
    WHERE (((tblPublicContact.CampusID)=[Forms]![frmTier1DataSearch]![cboCampusID]) AND ((Year([ContactDate]))=[Forms]![frmTier1DataSearch]![txtYear]));

  10. #10
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    What kind of relevant data?

  11. #11
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    We need the relevant parts are the query plus the two tables and form referenced by the query.
    Check that works correctly as a standalone db then upload it.
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Query1 is the query saved in step 1 of post 3. I think you use the name qryTier1Data1.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    I'm trying to attach the database. I'm not sure if this will go through.

    Tier1Data.zip

  14. #14
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204

    I've made everything appear !

    Hi

    Just had a quick look at this.
    I altered the Race field in the last 2 records to null (unknown) - both are for El Paso
    I then created a global query qryAll adding the field ContactRace: Nz(Race,"unknown") as mentioned before
    I also made the same change in each of your 3 queries

    You'll now see that Unknown appears for both of those records in each query

    You could also add an extra record to the tblRaceList table: 6 = unknown
    That would have the same effect as the Nz code

    Tier1Data-CR.zip
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  15. #15
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    It didn't work. Now it shows Hispanic Or Latino and Unknown. But the other races are not showing. I need all of the races showing regardless if there is any entry for them or not.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Making forms look better
    By Lou_Reed in forum Access
    Replies: 2
    Last Post: 04-18-2016, 12:56 PM
  2. Making changes to a Database to fit my needs
    By tsawrie in forum Database Design
    Replies: 1
    Last Post: 09-13-2012, 11:45 AM
  3. Making an equation
    By joce in forum Access
    Replies: 1
    Last Post: 10-27-2011, 09:56 AM
  4. Making changes to front end.
    By OrangePie in forum Access
    Replies: 4
    Last Post: 07-27-2011, 11:19 AM
  5. Help making 1 to 1 relationship
    By Rhino373 in forum Programming
    Replies: 2
    Last Post: 06-15-2011, 02:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums