我在VBA中遇到DCount问题。
我试图用Dcount计算的值填充数组。我在Dcount中使用的标准之一是我想要从不同的数组中获取,这就产生了问题:
Dim i As Integer
For i = 0 To (intNumberOfSplitterboxes - 1)
Dim arrFreeSingleModePorts(243) As Variant
arrFreeSingleModePorts(i) =
DCount("ID", "SplitterboxPorts", _
"SplitterboxID=i AND Mode='SingleMode' AND IsNull(DevicePortID) AND IsNull(SplitterboxPortID)")
Next
我收到错误2471
答案 0 :(得分:0)
您已在字符串中包含了i
变量。要在字符串中使用i
的实际值,您需要将它们连接在一起,如下所示:"SplitterboxID=" & i & " AND Mode='SingleMode' AND IsNull(DevicePortID) AND IsNull(SplitterboxPortID)"