Results 1 to 5 of 5
  1. #1
    desmonda is offline Novice
    Windows 8 Access 2013 32bit
    Join Date
    Aug 2016
    Posts
    6

    NEED HELP ASAP on using queries as a record source for forms

    For my assignment at school, I had to design a sport information system. One of my objectives was to create an information system where we can type in a student and their gender, and then the sport drop down list is filtered to only display sports where the genders are the same or the gender is unisex. I'm stuck on how to implement this. It keeps replicating the data. In my form, I want a person to enter in their gender and the next drop down combo box to filter the sports they can choose based upon this. Any help would be greatly appreciated. I've wasted soo much time on this now and it is due next week

    This is the current query I have.

    Select S.Sport
    From SportDetails AS S, StudentDetails AS T
    Where S.Gender = T.Gender OR S.Gender = "unisex'

    My teacher has created this code but it still does not work

    SELECT d.sport
    FROM studentdetails AS s, sportdetails AS d
    WHERE (s.gender = d.gender or s.gender = "unisex")


    and s.eqid like ["please enter an id"] & "*";

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    I don't see how the teachers will work.
    gender is on the student table. Sport.gender is the limiter to match.
    so you must have both table but not join them.
    the unisex will throw it off.
    i would use 2 different queries; 1 for unisex,1 for gender specific.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Any help would be greatly appreciated.
    I suggest you write a description of WHAT you are trying to do. You said in overview I had to design a sport information system. Then, you jumped into HOW you were doing certain things that are not working as expected.
    You are showing 2 tables.

    I don't know the details of your assignment or what your expected outputs/queries might be.
    Consider the following --and I could be way off-base with my first reaction:

    There are Many Students.
    Students are Categorized by Gender.
    Gender is restricted to Male, Female, Unisex
    There are Many Sports.
    Each Sport is categorized by Gender (same restriction as Student gender)
    A Student may participate in 1 or many Sports.

    tblStudent
    StudentID PK
    StudentFirstName
    StudentLastName
    StudentGender
    other student info

    tblSport
    SportID PK
    SportName
    SportGender
    other sport info

    You then say In my form, I want a person to enter in their gender and the next drop down combo box to filter the sports they can choose based upon this.


    So you form should have a control where the user can enter their gender. eg txtGender

    Your combobox -to show appropriately Sport names -- would need a rowsource that is filtered.

    The rowsource would be the tblSport and the filter/criteria would be the value entered into txtGender.
    However, for Gender ---unisex applies to all. So you must account for it in your filter/criteria.
    eg Where SportGender = Gender entered by user OR SportGender = unisex

    In order to show the filtered Sports in the combobox, you would need to Requery your form.

    I hope this is helpful.Click image for larger version. 

Name:	StudentSportF.jpg 
Views:	20 
Size:	79.6 KB 
ID:	25464Click image for larger version. 

Name:	studentSportM.jpg 
Views:	19 
Size:	80.0 KB 
ID:	25465

  4. #4
    desmonda is offline Novice
    Windows 8 Access 2013 32bit
    Join Date
    Aug 2016
    Posts
    6
    Hey, thanks for your help, how did you manage to filter the data?

    btw There are some sports eg. rugby that are not offered for girls. Each sport has a girl/boy variant and some have only one. The unisex ones are like debating

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    I mocked up your situation:

    tblStudent
    studentID Studentname StudentGender
    1 Bob male
    2 Sam male
    3 Jo female
    4 Joe male
    5 Josh male
    6 Tara female
    7 Sara female

    tblSport
    sportID sportName sportGender
    1 BasketballF female
    2 GymnasticsF female
    3 GymnasticsM male
    4 GymnasticsU unisex
    5 BasketballM male
    6 SwimmingU unisex
    7 CricketU unisex
    8 CricketM male

    On the form there is a textbox txtGender and a combo cboSport

    The AfterUpdate event of the txtGender is

    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub txtGender_AfterUpdate()
      Me.cboSport.RowSource = "Select * from tblSport where sportGender = 'unisex' or sportGender ='" _
                            & Me.txtGender & "'"
      Me.Requery
    End Sub

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

Similar Threads

  1. Replies: 16
    Last Post: 06-03-2014, 10:22 PM
  2. Replies: 8
    Last Post: 04-01-2014, 02:03 AM
  3. Replies: 5
    Last Post: 09-18-2013, 09:15 PM
  4. Replies: 2
    Last Post: 03-01-2012, 12:21 PM
  5. Forms' Record Source
    By Progress2007 in forum Programming
    Replies: 11
    Last Post: 07-27-2009, 11:04 AM

Tags for this Thread

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