Results 1 to 7 of 7
  1. #1
    cowboy is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2010
    Posts
    291

    Not using yes/no fields and still creating a table for check boxes ...

    Allen Browne has an page explaining how to set up a database relationship of many to many using a connection table at the following link
    http://allenbrowne.com/casu-23.html

    I can set up what he has done easily, but I want to be able to show the information much like the matrix he shows at the top of the page and also include in the query or form "sports" that no one has checked.



    Any help would be appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    That is displaying records horizontally (left to right). A crosstab query might work. Other methods are demonstrated in:

    http://forums.aspfree.com/microsoft-...ry-322123.html

    and another from Allen http://allenbrowne.com/func-concat.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.

  3. #3
    cowboy is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2010
    Posts
    291
    I couldnt get it to work with union or crosstab, I put together a copy of his example. I will attach and when I get it finally I will attach again for everyone to be able to see.StudentSports.zip

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Is this what you want:

    1. query StudSport
    SELECT [Surname] & ", " & [FirstName] AS StudName, Student.StudentID, Sport.Sport, StudentSport.StudentSportID
    FROM Student LEFT JOIN (Sport RIGHT JOIN StudentSport ON Sport.SportID = StudentSport.SportID) ON Student.StudentID = StudentSport.StudentID;

    Getting column for each sport even if noone has selected is tricky. One way is to put dummy records in StudentSport or fudge them with a UNION. Use this query as StudSport:
    SELECT [Surname] & ", " & [FirstName] AS StudName, Student.StudentID, Sport.Sport, StudentSport.StudentSportID
    FROM Student LEFT JOIN (Sport RIGHT JOIN StudentSport ON Sport.SportID = StudentSport.SportID) ON Student.StudentID = StudentSport.StudentID
    UNION SELECT "Dummy", "0", "Basketball", 1 FROM Student
    UNION SELECT "Dummy", "0", "Football", 2 FROM Student
    UNION SELECT "Dummy", "0", "Baseball", 3 FROM Student
    UNION SELECT "Dummy", "0", "Tennis", 4 FROM Student
    UNION SELECT "Dummy", "0", "Soccer", 5 FROM Student
    UNION SELECT "Dummy", "0", "Volleyball", 6 FROM Student
    UNION SELECT "Dummy", "0", "Ice Hockey", 7 FROM Student
    UNION SELECT "Dummy", "0", "Underwater Badmiton", 8 FROM Student;

    2. query StudSport_Crosstab
    TRANSFORM Count(StudSport.StudentSportID) AS CountOfStudentSportID
    SELECT StudSport.StudentID, StudSport.StudName
    FROM StudSport
    GROUP BY StudSport.StudentID, StudSport.StudName
    PIVOT StudSport.Sport;
    Last edited by June7; 05-10-2012 at 12:37 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.

  5. #5
    cowboy is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2010
    Posts
    291
    That works well for the current situation, but the whole reason for using a many to many relationship with a connection table is so that the program can be changed by adding a sport to the table and everything else falls in place. If I have to go in and put specific union code in for each sport I add, I could just as easily use check boxes from the start right?

  6. #6
    cowboy is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2010
    Posts
    291
    I had some help from another forum and I was able to get it working, just wanted to share the results with everyone.
    StudentSports.zip

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Of course, doh! All I had to do was reverse the join type of my first query and add the GROUP BY. I felt that tickle in back of my head telling me I was missing something and glad you got it solved.
    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.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. yes/no fields as check boxes
    By mejia.j88 in forum Reports
    Replies: 6
    Last Post: 01-30-2012, 10:01 AM
  2. How do I add multiple table entries using check boxes?
    By avarusbrightfyre in forum Access
    Replies: 3
    Last Post: 10-21-2010, 01:09 PM
  3. Replies: 3
    Last Post: 09-29-2010, 09:31 AM
  4. How to Query fields with check boxes?
    By JynxRD in forum Queries
    Replies: 2
    Last Post: 09-10-2010, 08:35 PM
  5. Creating Report using Text boxes & db fields
    By Nancy J. in forum Reports
    Replies: 13
    Last Post: 07-20-2009, 07:09 AM

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