I'm trying to replace access built-in search feature. I would like to find a record in the table, but searching in ANY FIELD. I have a table with about 10 fields. (Name, lastname, phone number etc), and I would like the record to search each field for a specific string,
I have this so far, but it doesn't work correctly..
Code:
Public Function FindRecord(FormToSearch As Form) As String
Dim vResult As Variant
vResult = InputBox("Type the criteria you wish to search for", "Find")
If IsNullString(vResult) Then
MsgBoxWrapper "You must enter a string to search for"
Else
Dim daoRecordSet As DAO.Recordset
Dim daoField As DAO.Field
Set daoRecordSet = FormToSearch.RecordsetClone
daoRecordSet.MoveFirst
Do While Not daoRecordSet.EOF
For Each daoField In daoRecordSet.Fields
If InStr(1, daoField.Value, vResult) Then
FormToSearch.Bookmark = daoRecordSet
End If
Next daoField
Loop
End If
End Function