访问搜索功能:如果未找到记录,则显示“不匹配”

时间:2016-09-30 16:41:26

标签: vba ms-access search access-vba

我在Access表单中实现了搜索功能。用户可以搜索以查看是否存在现有条目。我想这样做,如果用户搜索并且没有现有条目,将会显示“找不到匹配”。

到目前为止,我的VBA代码如下:

Private Sub Command49_Click()
Dim strsearch As String
Dim strtext As String
strtext = Me.txtSearch.Value
strsearch = "SELECT * from ID_Theft_Log where (ID like strtext)"
Me.RecordSource = strsearch
End Sub

我需要在代码中添加什么才能显示该文本?

1 个答案:

答案 0 :(得分:0)

IF strsearch.value = VbNullString Then
    MsgBox "Not Found"
End if