Results 1 to 3 of 3
  1. #1
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139

    Choose the first (and only) choice in a combobox

    I have a series of cascading combo boxes in frmGrades, In cboStudent I select a student from the list, cboCourse populates with only the courses that student is enrolled in, cboAssignments populates with only the ungraded assignments for that course, cboAssignmentWeight populates with the grading weight assigned to the assignment when the assignment is created. There is only one choice. I'd like to, if possible auto select that one choice in the "list." And, even hide the combobox so it is not visible but the one option is still written to the grades table.



    Thank you!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    each cbo box has a query that looks at the previous combo

    cboClasses query:
    select class from tClasses where [StudentID]=forms!myform!cboStudent

    cboAssingments:
    select [Assignment] from tAssignments where [StudentID]=forms!myform!cboStudent and [Class]=forms!myform!cboClasses

    when user picks a box item, refresh the combo and if it has 1 item , set it:
    Code:
    sub cboStudent_Afterupdate
    cboClasses.requery
    if cboClasses.listcount = 1 then 
       cboClasses = cboClasses.itemdata(0)
    
    cboClasses_Afterupdate
    endif end sub

  3. #3
    MichaelA is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2019
    Location
    Wisconsin
    Posts
    139
    On the last line before endif "cboClasses_Afterupdate" I receive a compile error "Sub or Function not defined"

    Never mind. I removed the offending line and it works.

    Thank you!



    Quote Originally Posted by ranman256 View Post
    each cbo box has a query that looks at the previous combo

    cboClasses query:
    select class from tClasses where [StudentID]=forms!myform!cboStudent

    cboAssingments:
    select [Assignment] from tAssignments where [StudentID]=forms!myform!cboStudent and [Class]=forms!myform!cboClasses

    when user picks a box item, refresh the combo and if it has 1 item , set it:
    Code:
    sub cboStudent_Afterupdate
    cboClasses.requery
    if cboClasses.listcount = 1 then 
       cboClasses = cboClasses.itemdata(0)
    
    cboClasses_Afterupdate
    endif end sub

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

Similar Threads

  1. multiple choice (with combobox? or list?)
    By ntambomvu in forum Forms
    Replies: 17
    Last Post: 04-29-2019, 08:46 AM
  2. Replies: 7
    Last Post: 09-14-2017, 02:24 AM
  3. Replies: 4
    Last Post: 03-22-2017, 08:00 AM
  4. Hide or disable value choice in combobox.
    By floyd in forum Programming
    Replies: 2
    Last Post: 11-16-2013, 12:20 PM
  5. Replies: 5
    Last Post: 07-23-2011, 11:48 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