Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Access (https://www.askmehelpdesk.com/forumdisplay.php?f=441)
-   -   Combox populated by current recordset / attendance (https://www.askmehelpdesk.com/showthread.php?t=297671)

  • Jan 1, 2009, 12:46 AM
    gwallace1
    Combox populated by current recordset / attendance
    I have a main form that is for entering data for an Event. Included in the form are two separate subforms. One is for Employee attendance and is a continuous form with a combobox that is populated by a query to the employee table. The second subform is for recording scores for the event. It is also a continuous form with a combobox that currently is populated exactly as the combobox for the attendance subform. Both subforms are linked to the main form by the EventID.

    What I want to do is have the combobox in the scoring subform query only the employees that were entered as attending the Event that is being entered.

    The tables are as follows:

    Event
    --------
    EventID (pk)

    Employees
    ------------
    EmployeeID (pk)

    EventAttendance jx table
    -----------
    EventID
    EmployeeID

    EventScores
    EventScoresID (pk)
    EventID(fk)

    I do not know how to query the current recordset on the form. Thanks for your time.
    Happy New Year!
  • Jan 1, 2009, 06:38 AM
    ScottGem

    This is done through a subquery, but I think you have a design problem. If I'm following you, Each employee gets scored for an event. If so, then then the event score is an attribute of the combination of employee and event, NOT an attribute of the event. So, in fact, the even score should be a field in the junction table, not a separate table. So your EventAttendance table would look like this:

    EventAttendanceID (PK Autonumber)
    EventID (FK)
    EmployeeID (FK)
    Score

    So you don't need the second table or subform.
  • Jan 1, 2009, 01:50 PM
    gwallace1

    Sorry I was not completely clear... I do have an employee ID in the EventScores tbl. I had typed a whole description of my design to explain it to you and in explaining it I see what you are saying and fixex it. Thanks for the help... I actually have six tables, three are scored individually for the employees that attend, three are not. By using what you pointed out, I eliminated the second subform in the three that are scored as I generate only a score for the employee that attended. The other three I only record attendance.
    For future reference... How is the subquery to populate the combobox designed, if one finds an application for it?
  • Jan 1, 2009, 05:40 PM
    ScottGem

    A subquery uses an IN clause as criteria with a SQL statement that returns one column.

    For example, if you wanted to show only employees registered for an event you would use something like this:

    IN(SELECT DISTINCT EmployeeID FROM tblEventAttendance WHERE EventID = Forms!formname!txtEventID)

  • All times are GMT -7. The time now is 10:40 PM.