Page 4 of 5 FirstFirst 12345 LastLast
Results 46 to 60 of 67
  1. #46
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Did you try:

    SELECT AttendeeReportQueryALL.*, People.Name


    FROM AttendeeReportQueryAll RIGHT JOIN People ON AttendeeReportQueryAll.Name = People.Name


    BTW, Name is a reserved word. Really should avoid reserved words in naming.
    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.

  2. #47
    BRZ-Ryan is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    187
    It is doing the same thing, except instead of all of the People table data, it only shows People.Name (to the right of my Name Count CountMon). I try to use People.Name as the Source for the name textbox but it gives me that same error as above.

  3. #48
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    If you want to provide db for analysis, follow instructions at bottom of my post. Identify objects involved in issue.
    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. #49
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I didn't read the whole thread but when June mentioned reserved name it made me think that something like this would be more appropriate.

    Code:
    SELECT AttendeeReportQueryALL.*, People.[Name]
     FROM AttendeeReportQueryAll RIGHT JOIN People ON AttendeeReportQueryAll.Name = People.[Name]

  5. #50
    BRZ-Ryan is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    187
    Thx all for your timeTestRpt.zip

  6. #51
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I can't figure out why that error but I expect it has something to do with nested query in AttendeeReportQueryAll.

    Why show both name fields on the report? Only pull one of the fields into query. If you want all the related info from People table then pull those fields into the query design.

    SELECT People.ID, People.Name, AttendeeReportQueryAll.Events, AttendeeReportQueryAll.CountMon, People.Email, People.Access
    FROM AttendeeReportQueryAll RIGHT JOIN People ON AttendeeReportQueryAll.Name = People.Name
    ORDER BY AttendeeReportQueryAll.Events DESC , AttendeeReportQueryAll.Name;

    Also, don't see need for the sorting in AttendeeReportQueryAll.


    Conventional approach with names is to store name parts in separate fields. As you have it now, can't sort by last name.
    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.

  7. #52
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I was able to get rid of the error by creating alias' for the Name fields. Seems the AttendeeReportQueryAll query is creating expressions that are somehow conflicting with the report's ability to bind its controls. Creating an alias for the expression field alone was not enough. In the end, I felt as though there must be a better approach than placing alias' everywhere (Like not including so many fields like June is suggesting?). Don't know if this info helps. FWIW anyway.....

  8. #53
    BRZ-Ryan is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    187
    Quote Originally Posted by June7 View Post
    Why show both name fields on the report? Only pull one of the fields into query. If you want all the related info from People table then pull those fields into the query design.

    Conventional approach with names is to store name parts in separate fields. As you have it now, can't sort by last name.
    I didn't want\need both names, that is how the query designer made the report when I selected the query. But it looks/works great now, thanks much for your time and patients.

    Yes, right now I have 2 versions of the db front-end, one experimental copy using comboboxes for name selection (individual) and one with a listbox\textbox (multi in one field). If I can get all of my reporting to work properly with the combo method I will go with that. However, the end-users are ok with first-name sorting and there should not be a need for sorting beyond what you provided here. I'm not comfortable with the combo method because it is more confusing to me right now. This was my first project/experience with Access. I have years of programming eduction\experience in VB\Pawn\C but I've never touched Access. I am interested in learning more though. What do most users use to write SQL? Manually in notepad or w\e or with the Design view? I feel like design view could help me out but I'm still not sure how to properly use it.

    Also, I am working on another project where I have a similar objective and I did use an independent table for attendance. Learning more every day.

  9. #54
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    The query builder Design View will help you build most of the queries you will need. Even if nested queries are desired the builder can help. Build the inner query first. Build outer query that uses the first query. Copy/paste the SQL of first query into the second query. I use copy/paste a lot in the SQL View window. Some queries must be constructed in SQL View and won't even display in Design View - UNION comes to mind.
    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.

  10. #55
    BRZ-Ryan is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    187
    What's the principle behind nested queries? Is that querying from another query? And whats the basic layout?

    SELECT A FROM (SELECT B FROM C WHERE A=1)? In experimenting with these, I get confused on where to reference the table in the FROM..ie, which FROM do I put the tables.

  11. #56
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Nested queries can involve several tables or one table.

    A nested query is often utilized when selection of records depends on values in other records of same table. Another use is to calculate with values of sequential records. Review http://allenbrowne.com/subquery-01.html
    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.

  12. #57
    BRZ-Ryan is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    187
    Quote Originally Posted by June7 View Post
    This would be so easy with an aggregate query if the data were normalized. Even a multi-value field would be manageable and I don't like multi-values. A delimited string is the worst arrangement for this sort of data analysis.

    I could get this to work only with a unique ID field in each table. I used an autonumber type.

    SELECT Name, Count(People.ID) AS CountAttendance
    FROM (SELECT Events.ID, People.ID, Name, Attendees, Role
    FROM Events, People
    WHERE InStr([Attendees],[Name])>0 AND Role="Attendees") AS Q1
    GROUP BY Name;


    BTW, Name is a reserved word and should not use reserved word as fieldname.
    I've since went with the normalized method and am working on the counts (total and mondays), can someone please assist? My numbers are coming out too high, and I can't figure out why. Can someone please review and explain what was wrong and how to fix?
    Code:
    SELECT LastName, Count(People.ID) AS CountAttendance, Sum(Q1.Mon) AS CountMon
    FROM (
    SELECT People.ID, People.LastName, People.Role, IIf(Weekday([Events.EventDate])=2,1,0) As Mon
    FROM Events, People, Attendance
    WHERE (((Attendance.EmployeeID=People.ID) AND (People.Role="Attendee")) AND ([EventDate] BETWEEN #1/1/2013# AND #1/1/2014#))
    ) AS Q1
    GROUP BY LastName;

  13. #58
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Do you want to provide latest version of the db?
    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.

  14. #59
    BRZ-Ryan is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    187
    Thanks..and can you explain the routine in words on how you would do each count?

    dbTest.zip

  15. #60
    BRZ-Ryan is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    187
    Ok, I have the counts working. Now I just need to get it to show people with 0 counts. I also noticed I have Attendee mis-spelled for one of the people in tblPeople, so if your test counts are off that's why.

    Code:
    SELECT Q1.LastName, Count(tblPeople.ID) AS CountAttendance, Sum(Q1.Mon) AS CountMon
    
    FROM (SELECT tblPeople.ID, tblPeople.LastName, tblPeople.Role, IIf(Weekday([tblEvents.EventDate])=2,1,0) AS Mon 
    
    FROM tblEvents, tblPeople, tblAttendance 
    
    WHERE ((tblAttendance.EmployeeID=tblPeople.ID) AND (tblEvents.ID = tblAttendance.EventID) AND (tblPeople.Role="Attendee") AND ([tblEvents].[EventDate] BETWEEN #01/01/2013# AND #01/01/2015#))) AS Q1
    
    GROUP BY Q1.LastName;

Page 4 of 5 FirstFirst 12345 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 11-27-2013, 05:24 PM
  2. Replies: 9
    Last Post: 05-08-2013, 02:37 PM
  3. Replies: 1
    Last Post: 06-08-2012, 11:14 AM
  4. combo box query based on different query result?
    By mejia.j88 in forum Queries
    Replies: 10
    Last Post: 02-15-2012, 02:00 PM
  5. Query result based upon two field conditions
    By diane802 in forum Access
    Replies: 35
    Last Post: 01-08-2010, 06:31 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