【问题标题】:put checkbox value to number field in Ms Access将复选框值放入 M​​s Access 中的数字字段
【发布时间】:2016-10-16 12:31:26
【问题描述】:

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

PcType as Number
type1  check1, type2 check2, type3 check3

何时:

type1 checked -> PcType = 1

type2 checked -> PcType = 2

type1 & type2 checked -> PcType = 4

等等..

【问题讨论】:

标签: ms-access vba ms-access-2010


【解决方案1】:
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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-24
    • 1970-01-01
    • 1970-01-01
    • 2019-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多