ms-access - MS Access VBA布尔值本地化问题
问题描述
我在 MS Access 数据库(当前 Office 365 Access 版本)中的 VBA 中构建了一些 SQL 查询字符串,我遇到了从表单控件读取的布尔值的奇怪本地化问题:Me.MyBooleanControl
返回“Wahr”(德语“True”)=> 生成SQL 失败。
我现在正在使用一种解决方法,通过一个函数包装每个值请求,以将值转换为-1
/0
就像这里建议的那样,但我真的很想知道是否有直接的方法来避免这种情况。去年我在另一个没有遇到相同问题的 Access 数据库中使用了相同的代码结构 - 我完全不知道有什么不同(除了 MS Office 我已经更新)。
编辑:我找到了解决方案,请参阅下面的答案。
解决方案
Trying to reproduce the problem independently from the rest of my code, I nailed it down and found it to be my fault: I initialized the unbound checkbox as True
which seemed to work fine, but causes the problem:
Private Sub Form_Load()
Me.UnboundCheckbox01 = True
Me.UnboundCheckbox02 = -1
End Sub
Private Sub ReadCheckBox()
Debug.Print Me.UnboundCheckbox01 ' returns localized value "Wahr"
Debug.Print Me.UnboundCheckbox02 ' returns -1 as expected
' after manually toggeling UnboundCheckbox01 to unchecked
' and back to checked again, the value returns as -1 too
End Sub
Sorry! Next time I'll honor the rules and provide some code - sometimes the question dissolves by just doing that...
推荐阅读
- vba - 循环遍历文件夹并将 .csv 文件转换为 .txt 文件的 Visual Basic 代码
- vb.net - 'radius' 不是 VB.NET 中的参数
- regex - 正则表达式 - 从 www.anything.com 中提取单词
- python - How to make predictions using a saved RandomForest model from Orange GUI
- pygame - 玩家不动
- python - 在 python 中的 Python 中创建函数时出错
- spring-mvc - 我如何在多个复选框上调用控制器类中的方法来更新spring mvc中的记录
- dart - NoSuchMethodError:方法 'ancestorStateOfType' 在 null 上被调用
- python-3.x - Python 值错误:无法将字符串转换为浮点数据帧(如何找到值的位置)
- laravel-5.6 - 尝试创建“添加类别”字段。未找到 Laravel 错误列: