Private Sub btnsearch_Click()
Dim strText As String
Dim rst As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT * FROM SearchStudent "
strText = "1 "
If Not IsNull(Me.[Name]) Then
strText = strText & " AND [Name] like '*" & Me.[Name] & "*' "
End If
If Not IsNull(Me.[StudentID]) Then
strText = strText & " AND [StudentID] = '" & Me.[StudentID] & "'"
End If
If Not IsNull(Me.[Contact]) Then
strText = strText & " AND [Contact] Like '*" & Me.[Contact] & "*' "
End If
If Not IsNull(Me.[Email]) Then
strText = strText & " AND [Email] = '" & Me.[Email] & "'"
End If
If strText <> "1 " Then
strSQL = strSQL & " WHERE " & strText
Set rst = CurrentDb.OpenRecordset(strSQL)
If Not rst.EOF Then
Set SearchSubForm_1.Form.Recordset = rst
Else
MsgBox "Nothing Found"
End If
Else
btnclear_Click
End If
End Sub