【问题标题】:ms access - option button value -1 when selectedms 访问 - 选择时选项按钮值 -1
【发布时间】:2014-06-09 21:04:43
【问题描述】:

我有一个带有控制源的选项按钮。该按钮不是选项组的一部分。 When the button is not selected it stores 0 (which is what I want) however, when the option button is selected it stores -1 instead of 1. I cannot seem to find the property in the menu to set the option value.

有没有办法在选择为1而不是-1时设置存储值?

我尝试了 Me.Controls("optionButtonControlName").OptionValue = 1 但出现错误。

我知道我能做到:

If (optBtn.Value = -1) Then
    optBtn.Value = 1
End If

每次单击按钮时,都必须有一种更简单的方法来执行此操作,而我只是没有看到。

谢谢!

【问题讨论】:

  • 分配-1时被设置为True
  • 使用更新后事件并检查它是否设置为-1。如果是这样,则将另一个控件设置为1。也许是一个隐藏的控件。
  • 非常感谢!我使用了您对 AfterUpdate 方法的建议和获得绝对值的@XIVSolutions 建议。

标签: ms-access vba


【解决方案1】:

在 Access 中(我记得一般在 VBA 中),真值始终为 -1。选项按钮本身(以及任何其他在 VB/VBA 中设置布尔值的控件)在 true 时将始终显示此值。

一个不太冗长的选项可能是获取控件的绝对值:

myValue = Abs(optBtn.Value)

【讨论】:

  • 谢谢!完美运行!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-20
  • 2018-12-29
  • 1970-01-01
相关资源
最近更新 更多