I am trying to mimic in Access 2007 a capability I had commonly coded in Paradox / Object PAL. For forms with many fields and records, I would code up a "search-as-you-type" capability. The search should be performed on the form's current sort by column.
I never see the FindFirst actually find based on searching for a partial string. My code is as follows:
I have four records in the test database table. "First Part", "Second Part", "Third Part", and "Fourth Part". I have it sorted by the title column, so "Second Part" is third in the list. Starting from the top record, I enter "Se" into the search fldFind field, click the find button, and I do not receive a hit.
In the final state, I indent to fire this code on the AfterUpdate event of the field control, and convert the button to an enable/disable toggle for the search capability.
Suggestion on how to implement "search-as-you-type" in Access VBA? TIA!
I never see the FindFirst actually find based on searching for a partial string. My code is as follows:
Code:
Private Sub btnFind_Click()
Dim strFindInCol
Dim daoRS As DAO.Recordset
'Find out which column is currently being sorted by
If InStr(strCurrentSort, " ") = 0 Then
strFindInCol = strCurrentSort
Else
strFindInCol = Mid(strCurrentSort, 1, InStr(strCurrentSort, " ") - 1)
End If
'Attach to the Form's record set
Set daoRS = Me.RecordsetClone
daoRS.FindFirst ("[" & strFindInCol & "] = " & Chr(34) & Me.fldFind.Value & "*" & Chr(34))
'If we could find a match, jump to it
If Not daoRS.NoMatch Then
Me.Bookmark = daoRS.Bookmark
End If
End Sub
In the final state, I indent to fire this code on the AfterUpdate event of the field control, and convert the button to an enable/disable toggle for the search capability.
Suggestion on how to implement "search-as-you-type" in Access VBA? TIA!