1

我正在使用 Access 制作学生数据库。作为我的数据库的一部分,我有一个表格,要求用户从组合框中选择一门课程。我有不同的课程术语,对应于他们从下拉框中选择的课程。为了保持一致性,还使用下拉框选择术语。

在我的代码中,我有一个After_Click带有以下代码的事件过程:

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

当我第一次单击表单时,所有术语下拉框都会显示。我如何设置它(在 VBA 代码中),以便默认情况下显示与默认值Term ID对应的并且隐藏Course ID其余的Term ID下拉框?

汤姆

我附上了默认的截图Course ID。请注意,所有组合框似乎都是可见的。

在此处输入图像描述

4

2 回答 2

0

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?

于 2012-05-04T22:39:47.060 回答
0

选项 1 定义默认课程并在表单的初始加载时,使其预先选择并具有相应的组合框可见 使其余组合框默认不可见(即,通过将其余组合框的可见属性设置为设计时为假)

选项 2 如果您不能拥有默认课程,则默认情况下使所有术语组合框不可见。因此,最初根本没有可用的术语组合框。

于 2012-05-04T01:30:16.200 回答