查看下面的以下代码行。
Dim rst As DAO.Recordset
Dim strSql As String
strSql = "SELECT * FROM MachineSettingsT;"
Set rst = DBEngine(0)(0).OpenRecordset(strSql)
rst.FindFirst "Microwave = " & "'" & Me.Microwave & "'" & " AND WashingMachine =" & "'" & Me.WashingMachine & "'" & " AND Element1 =" & "'" & Me.Element1 & "'" _
& "AND Element3 =" & "'" & Me.Element3 & "'" & "AND Dryer =" & "'" & Me.Dryer & "'" & "AND SettingID <>" & "'" & Me.SettingID & "'"
If Not rst.NoMatch Then
Cancel = True
If MsgBox("Setting already exists; go to existing record?", vbYesNo) = vbYes Then
Me.Undo
DoCmd.SearchForRecord , , acFirst, "[SettingID] = " & rst("SettingID")
End If
End If
rst.Close
问题:如果 rst.FindFirst 表达式中的任何值为 Null,则 rst.NoMatch 始终返回 true,即使在正在评估的字段中存在具有匹配 Null 值的记录。这种行为是可以预期的还是可能存在另一个潜在问题。我检查了msdn页面,但它没有提供有关此类行为的信息。