将复选框值放入 M​​s Access 中的数字字段

put checkbox value to number field in Ms Access

我在 MS 访问中有 3 个复选框,我想将特定数字放入数字字段 当检查每一个时,例如

PcType as Number
type1  check1, type2 check2, type3 check3

时间:

type1 checked -> PcType = 1

type2 checked -> PcType = 2

type1 & type2 checked -> PcType = 4

等等..

If Me.Type1 = True and Me.Type2 = False Then
    PCType = 1
ElseIf Me.Type2 = True and Me.Type1 = False Then
    PCType = 2
ElseIf Me.Type1 = True and Me.Type2 = True Then
    PCType = 4
ElseIf ... <further conditions go here>
End If    

假设您想为每个不同的场景硬编码 PCType 的值(即,当仅选中 check1 和 check3 时设置不同的 PCType 值,当所有三个都选中时设置另一个唯一值等) )

您还可以使用分支 if 语句进一步简化它:

If Me.Type1 = True Then
    If Me.Type2 = False Then
        PCType = 1
    ElseIf ...
    End If
End If

然而,根据您提供的信息,很难举出这方面的例子。