使用文本框搜索数据库AfterUpdate

时间:2018-03-06 01:58:48

标签: access-vba ms-access-2010

我有一个数据输入表单,我想要一个特定的文本框来执行表的搜索,以查找在文本框中输入的数据是否已经存在于表的相关字段中。这是我目前的代码,它返回rst.FindFirst "[SuperPNR] = & SuperPNR"上数据类型错误的不匹配 这让我很困惑......

Private Sub SuperPNR_AfterUpdate()
If (SuperPNR & vbNullString) = vbNullString Then Exit Sub
Dim dbs As DAO.Database
Dim rst As DAO.Recordset

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Travel Fraud Data - Test")

rst.FindFirst "[SuperPNR] = & SuperPNR"
If rst.NoMatch Then

Else
    MsgBox "Record Already In Database!", vbOKOnly + vbInformation, "Do Not Save Record!"
End If
rst.Close
Set rst = Nothing
Set dbs = Nothing

End Sub

0 个答案:

没有答案