Enabling/disabling 根据另一个字段的值输入到某个记录的字段,但在同一条记录

Enabling/disabling input into certain record's field based on the value of another field, but at the same record

我使用 Access 2016,我正在尝试 lock/unlock 每条记录中的字段(Epileptic_activity、Quantifiable_activity 和 Seizure_aspect),当 "Selection"=No/Yes 分别(我选择了 Yes/No)。所有这些都发生在大导航窗体的子窗体中。

我用了这个方法 Enabling/disabling input into certain fields based on the value of another field 它有效,但它 locks/unlocks 显示在表单中的所有数据。 一旦我将任何选择选中为是,所有记录都已解锁 Epileptic_activity、Quantifiable_activity 和 Seizure_aspect。

这是我使用的代码:

Private Sub Selection_AfterUpdate()

Me.Epileptic_activity.Enabled = True

Me.Quantifiable_activity.Enabled = True

Me.Seizure_aspect.Enabled = True

If (Me.Selection = False) Then

    Me.Epileptic_activity.Enabled = False

    Me.Quantifiable_activity.Enabled = False

    Me.Seizure_aspect.Enabled = False

    End If

End Sub

所以,我希望能够 lock/unlock 记录 Selection 之后的字段,因为在一条记录中我们可以有 Selection 并且以下字段是必需的,但下一条记录没有 Selection= "yes" 然后我希望锁定以下 3 个字段。

我怎样才能让它发挥作用?

感谢任何帮助

您无法更改它,这是 Access 的工作方式。

但是,您可以通过检查 Selection 值,在每次控件获得焦点时单独 enable/disable 每个控件。

Private Sub Epileptic_activity_Enter()

    If Selection.Value = False Then Epileptic_activity.Enabled = False Else Epileptic_activity.Enabled = True

    'or simply

    Epileptic_activity.Enabled = Selection.Value

End Sub

您需要对所有三个控件执行此操作。