This is driving me crazy,
over the years ended up having lots of different tricks to achieve this but always messy & all over the place. There must be a clean & proper way.
Basically I have a text box. I type a name & it filters the form.
For speed & ease I type the name, either press tab or enter. Don't want to have to reach for the mouse each time or have to let it tab to a button to press space or something.
I want it to stay on the search textbox and highlight, ready to over type.
I use me.filter usually in AfterUpdate but mostly OnExit letting it naturally tab to another control & then back again. This is always tricky as not lost focus yet can't easily move focus around.
Whole host of issues with this in either procedure.
AfterUpdate I would think is the obvious but you can never highlight.
Me!FindNames.SelStart = 0
Me!FindNames.SelLength = Len(FindNames.Text)
At it hits the end sub in the AfterUpdate I guess it is reset as this looses the highlighting & cursor is at the start of the textbox, you have to delete previous. I often want to keep what is types also so not auto delete.
I have looked at before update & cancel = true but this seems to bring up a whole different set of issues.
this is what I thought should work & be so simple but stepping through all highlighted OK but as soon as you F8 on End Sub if clears.
Private Sub FindNames_AfterUpdate()
Me.Filter = "Names Like '*" & [Forms]![regFAYT]![FindNames] & "*'"
Me.FilterOn = True
Me!FindNames.SelStart = 0
Me!FindNames.SelLength = Len(FindNames.Text)
End Sub
Actually bit confused at this minute as does not seem to be moving onto the next control at the moment no matter what I do. Sure use to. I know this is effectively re-querying so perhaps updating in a loop but odd as sure used lots of times, will investigate but sorry to post an incomplete question now..
over the years ended up having lots of different tricks to achieve this but always messy & all over the place. There must be a clean & proper way.
Basically I have a text box. I type a name & it filters the form.
For speed & ease I type the name, either press tab or enter. Don't want to have to reach for the mouse each time or have to let it tab to a button to press space or something.
I want it to stay on the search textbox and highlight, ready to over type.
I use me.filter usually in AfterUpdate but mostly OnExit letting it naturally tab to another control & then back again. This is always tricky as not lost focus yet can't easily move focus around.
Whole host of issues with this in either procedure.
AfterUpdate I would think is the obvious but you can never highlight.
Me!FindNames.SelStart = 0
Me!FindNames.SelLength = Len(FindNames.Text)
At it hits the end sub in the AfterUpdate I guess it is reset as this looses the highlighting & cursor is at the start of the textbox, you have to delete previous. I often want to keep what is types also so not auto delete.
I have looked at before update & cancel = true but this seems to bring up a whole different set of issues.
this is what I thought should work & be so simple but stepping through all highlighted OK but as soon as you F8 on End Sub if clears.
Private Sub FindNames_AfterUpdate()
Me.Filter = "Names Like '*" & [Forms]![regFAYT]![FindNames] & "*'"
Me.FilterOn = True
Me!FindNames.SelStart = 0
Me!FindNames.SelLength = Len(FindNames.Text)
End Sub
Actually bit confused at this minute as does not seem to be moving onto the next control at the moment no matter what I do. Sure use to. I know this is effectively re-querying so perhaps updating in a loop but odd as sure used lots of times, will investigate but sorry to post an incomplete question now..