Dropdown Report Menu on a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Stoic
    New Member
    • Jun 2012
    • 68

    Dropdown Report Menu on a form

    Hi,
    I have a database with school information. On the reporting form, I have a dropdown combo that contains list of teachers by schools. The problem I am having is, when I select the dropdown, instead of listing individual school, it list a school five times, for an example, meaning there are five teachers at that school.
    Is is possible to have my dropdown list just the school even if it has more than one teacher?

    This is what I have so far: ADezii helped me with this some time ago.

    Code:
    Private Sub Command84_Click()
    
    If Me![cboSchoolCode] = "--select--" Then Exit Sub
    
    DoCmd.OpenReport "rptInServiceIndividualSchoolAndTeachersInformation", acViewReport, , "lngSchoolCode = '" & Me.cboSchoolCode & "'"
     
    cboSchoolCode = "--select--"
    
    End Sub
    Last edited by TheSmileyCoder; Sep 20 '12, 03:42 PM. Reason: Added [Code] ... [/Code] tags for you
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    If I'm understanding you correctly, only the school is listed, but each school is being listed once for each teacher at the school. This means that the row source needs changed. Usually, you would have a table of schools separate from the table of teachers, in which case you would need the row source to query the schools table. If for some reason you don't have the separate schools table, then you would query your table for DISTINCT records. For example:

    Code:
    SELECT DISTINCT [School]
    FROM [table]
    WHERE [if needed]
    If you need further help on this, post the code that is in your row source. If it is the name of a query, then open that query in SQL view and post that code. Make sure to use code tags (the button that says <code/>)

    Comment

    • Stoic
      New Member
      • Jun 2012
      • 68

      #3
      Thanks for the add.
      This is what I have:

      Code:
      SELECT 
         tblTeachersProfile.lngSchoolCode,
         tblTeachersProfile.strSchoolName 
      FROM tblTeachersProfile 
      ORDER BY tblTeachersProfile.strSchoolName;
      Last edited by zmbd; Sep 20 '12, 07:05 PM. Reason: Placed the [CODE]...[/CODE] tags (please use <CODE/> format button) -z

      Comment

      • Seth Schrock
        Recognized Expert Specialist
        • Dec 2010
        • 2965

        #4
        Did you try the SELECT DISTINCT in there? What were the results?

        Comment

        • Stoic
          New Member
          • Jun 2012
          • 68

          #5
          Thanks Seth,
          It works just as I wanted.

          Comment

          • Seth Schrock
            Recognized Expert Specialist
            • Dec 2010
            • 2965

            #6
            Not a problem. Please click on the Choose as Best Answer.

            Comment

            Working...