如何使用外部变量验证数据是否存在于记录集中? VBA
How verify if a data exist in a recordset with an external variable? VBA
我想验证此记录集中是否存在特定变量 (oLookFullName) 的值,如果不存在,我想打印一条消息,所以我尝试了这个:
rs.MoveFirst
filter2 = "[Nom] = " & oLookFullName
rs.Find filter2
If (rs.BOF = True) Or (rs.EOF = True) Then
Debug.Print oLookFullName & " is not find"
End If
但是我在 rs.Find filter2
:
行出现了这个错误
Run-time error 3001 Arguments are of the wrong type or out of acceptable range or are in conflict with one another.
对于 DAO,尝试使用:
filter2 = "[Nom] = '" & oLookFullName & "'"
rs.FindFirst filter2
If rs.NoMatch Then
Debug.Print oLookFullName & " is not found."
End If
对于 ADO,尝试使用:
filter2 = "[Nom] = '" & oLookFullName & "'"
rs.MoveFirst
rs.Find filter2
If rs.EOF Then
Debug.Print oLookFullName & " is not found."
End If
我想验证此记录集中是否存在特定变量 (oLookFullName) 的值,如果不存在,我想打印一条消息,所以我尝试了这个:
rs.MoveFirst
filter2 = "[Nom] = " & oLookFullName
rs.Find filter2
If (rs.BOF = True) Or (rs.EOF = True) Then
Debug.Print oLookFullName & " is not find"
End If
但是我在 rs.Find filter2
:
Run-time error 3001 Arguments are of the wrong type or out of acceptable range or are in conflict with one another.
对于 DAO,尝试使用:
filter2 = "[Nom] = '" & oLookFullName & "'"
rs.FindFirst filter2
If rs.NoMatch Then
Debug.Print oLookFullName & " is not found."
End If
对于 ADO,尝试使用:
filter2 = "[Nom] = '" & oLookFullName & "'"
rs.MoveFirst
rs.Find filter2
If rs.EOF Then
Debug.Print oLookFullName & " is not found."
End If