我有一个访问配置表,其中包含多行可能的配置(即类型 = 位置变量 = 代理 I、代理 II、代理 III)
**Type** **Description**
Position Agent I
Position Agent II
Position Agent III
我想将另一个 SQL 中的字段与此处列出的位置相匹配。
If str = one of the positions listed in the Config table then Boolean = True
Else
'make a change
end if
我该如何实现这个目标?
也许使用 DCount() 函数返回找到的符合条件的记录数?不太清楚你要问什么。
Public Function IsFound(ByVal stringType As String, ByVal stringValue As String) As Boolean
IsFound = DCount("*","Config","[Type]='" & stringType & "' AND [Description]='" & stringValue & "'") > 0
End Function
然后:
Dim strType As String: strType = "Position"
Dim strValue As String: strValue = "Agent I"
If IsFound(strType, strValue) Then '...
也许您可以省略类型并仅查找值,但我还没有完全理解您的问题。