【发布时间】:2015-04-15 03:39:52
【问题描述】:
我有一个 VBA 函数,它根据输入的一个参数返回布尔值(真/假)。我试图将此函数插入 Access 表单上的验证规则中。
验证规则:
MyFunction ([My Field])
VBA 中的 MyFunction:
Public Function MyFunction(str as String) as Boolean
MyFunction=Len(str)>4 'Just as an example, the actual function is a bit more complex, but still returns true when expected and false when expected. This has been observed when stepping through the actual VBA code
End Function
我可以在 VBA 中看到该函数确实被调用,并且它按预期返回 true 和 false,但由于某种原因,无论函数实际返回什么,Access 仍然看到 [My Field] 的值无效(注意:[My Field] 是一个没有输入掩码的文本字段)。
那么,我必须怎么做才能让我的 VBA 函数返回的“真”值在我的验证规则中注册为有效值?
我正在使用 Access 2010。
【问题讨论】:
标签: validation ms-access vba ms-access-2010