这是我的代码:
Private Sub Command34_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("sus-Table", dbOpenDynaset)
Dim temp As String
If Nametxt = rs![Name] And ID = rs![ID] And Address_1 = rs![Address 1] _
And Address_2 = rs![Address 2] And City = rs![City] And State = rs![State] Then
MsgBox "True"
Else
MsgBox "False"
End If
End Sub
使用此代码,只要填充了所有字段(当然它们匹配),它就会返回true。
然而,如果一个字段即。地址2为空,因为并非所有地址都需要第二行,即使它们匹配,也会返回“False
”。
即使它们是空的,我也不确定如何比较它们。
非常感谢您对此事的任何帮助。
答案 0 :(得分:0)
这听起来像是将空与 Nulls 进行比较的老问题,我建议像这样重写:
And Address_2 & "" = rs![Address 2] & ""