แก้โค้ดเป็น
Private Sub Searchcriteria()
Dim sql As String
Dim FindRecordCount As Long
Dim rstRecords As Recordset
sql = "SELECT * FROM Ptt WHERE [Name] like '*" & Nz(Me.TextSearch, "*") & "*' and [Sex] like '" & Nz(Me.Combo1, "*") & "' and [Dep] like '" & Nz(Me.Combo2, "*") & "' and [Age] like '" & Nz(Me.Combo3, "*") & "'"
Set rstRecords = CurrentDb.OpenRecordset(sql)
forms!.....................recordsource = sql
forms!.....................Requery
If rstRecords.EOF Then
FindRecordCount = 0
Else
rstRecords.MoveLast
FindRecordCount = rstRecords.RecordCount
End If
If FindRecordCount = 0 Then
MsgBox "Not Found !!", vbCritical, "Status"
End If
End Sub