访问VBA复选框错误2447



好的,我在尝试在数据库中创建新记录时收到错误 2447。 这是有的代码。

'This checks the record each time a record is changed to see if it needs to display the text boxes
Private Sub Form_Current()
If Me.SigCheck = 1 then <--This is where I'm getting the error.
SigSerialtxt.Visible = True
SigSeriallbl.Visible = True
SigAssettxt.Visible = True
SigAssetlbl.Visible = True
Else
SigSerialtxt.Visible = False
SigSeriallbl.Visible = False
SigAssettxt.Visible = False
SigAssetlbl.Visible = False
End if
End Sub

我试图将变量更改为 True 和 -1,但两者都不起作用。 我不知道该用什么。

修复了这个问题,我将默认值设置为 0,现在没有错误并且可以正常工作。

我知道你已经想通了,但如果有人像我一样,以后偶然发现这篇文章,我想添加另一个答案。

您还可以执行一些值/错误检查。例如,您还可以执行以下操作:

if IsNull(Me.SigCheck)=false AND Me.SigCheck=1 Then
...
end if

或者,您也可以将 true 用于 1,false 表示 0。我相信一个空复选框的中间有正方形。

最新更新