1
votes

I am making a student Database using Access. As part of my database i have a form that requires users to select from combo boxes a course. I have different course terms available corresponding to which course they select from the drop down box. The terms are also selected using a drop down box, for consistency.

In my code I have an After_Click event procedure with the following code:

Private Sub Course_ID_AfterUpdate()

  If Me![Course ID] = 1 Or Me![Course ID] = 2 Or Me![Course ID] = 3 Then
  Me![Combo30].Visible = True Else: Me![Combo30].Visible = False End If

  If Me![Course ID] = 4 Then Me![Combo26].Visible = True Else:
  Me![Combo26].Visible = False End If

  If Me![Course ID] = 5 Then Me![Combo22].Visible = True Else:
  Me![Combo22].Visible = False End If

  If Me![Course ID] = 6 Then Me![Combo28].Visible = True Else:
  Me![Combo28].Visible = False End If

  If Me![Course ID] = 7 Then Me![Combo24].Visible = True Else:
  Me![Combo24].Visible = False End If

End Sub

When i first click the form all of the term drop down boxes are displaying. How do i set it (in VBA code) so that by default the Term ID corresponding to the default Course ID is displayed and the rest of the Term ID drop down boxes are hidden?

Tom

I have attatched a screenshot of the default Course ID. Notice all of the combo boxes appear to be visible.

enter image description here

2

2 Answers

0
votes

Option 1 Define a default course and on initial load of the form, make it pre-selected and have the corresponding combo box visible Make rest of the combo boxes invisible by default (ie, by setting the visible property of rest of the combo boxes to false at design time)

Option 2 If you can not have a default course then make all of the terms combo boxes invisible by default. So that, initially there are no terms combo boxes available at all.

0
votes

In a continuous form, every control existss only once over all the records. You cannot have different formatting on the same control in different records. As soon as you hide a control in one record it is hidden in all records.

What do you have in those boxes? is there a chance to have one combo that could be filled in the OnEntring event?