在VBA中修复types不匹配错误13

我是新来的编码,并试图开发一个用户表单,允许我填充数据库。

我正在尝试设置一些可以通过用户窗体input到数据库的数据validation。

我正在使用的代码如下所示Reg是我的用户窗体上的控件的名称。

当我运行这部分代码时,它停在第一行,并显示types不匹配错误13消息框。

任何帮助,你可以给予非常感激。

Sub ValidCombo1() If Reg18.Value = "" And ((Reg17.Value <> "1" Or (Reg15.Value <> "0" Or "") Or Reg16.Value <> "A" Or Reg19.Value <> "") Or (Reg17.Value <> "" And Reg15.Value <> "" And Reg16.Value <> "" And Reg19.Value <> "")) Then MsgBox "Invalid Foundations combination" Reg13.Value = "" ElseIf Reg25.Value = "" And ((Reg24.Value <> "1" Or (Reg22.Value <> "0" Or "") Or Reg23.Value <> "A" Or Reg26.Value <> "") Or (Reg24.Value <> "" And Reg22.Value <> "" And Reg23.Value <> "" And Reg26.Value <> "")) Then MsgBox "Invalid Inverts and Aprons combination" Reg13.Value = "" 

您的代码可能有其他问题,但expression式

 Reg15.Value <> "0" Or "" 

是一种types不匹配。 ""是一个string,不是一个布尔值。

replaceReg15.Value <> "0" Or ""

 Reg15.Value <> "0" And Reg15.Value <> "" 

(我认为是你的意图)将消除这些types的不匹配。