R
RGBrighton
Hi,
I have a simple, continous form based on a single table.
The records are displayed by order of 'modulecode' - a string of about 5
characters.
I have placed an unbound textbox (txtModuleCodeFilter) in the form header
which I hope to use to type in a couple of characters and have the form
filter to modulecodes starting with those characters.
The code below works fine.
The problem is that after a single keystroke in the textbox the filter
changes but then the whole text in the textbox is highlighted; so the next
keystroke overwrites the previous one!
I need to filter to 2 or 3 characters but to do this I have to keep clicking
the cursor to the end of the textbox before typing the next character.
How can I arrange this so that the user can just type a few characters in
the textbox and have the filter respond immediately to each successive
keystroke?
I hope to avoid the 2-stage: 'Type in the box then click button for filter'
approach.
Here is the code:
Private Sub txtModuleCodeFilter_Change()
Dim L As Integer
Dim CodeSelected As String
CodeSelected = Nz(txtModuleCodeFilter.Text)
'Filter the form to start like the textbox
If CodeSelected = "" Then
Me.FilterOn = False
Else
L = Len(CodeSelected)
Me.Filter = "left(ModuleCode, " & L & ") = '" & CodeSelected & "'"
Me.FilterOn = True
End If
End Sub
Any suggestions gratefully received.
Thanks
Richard
I have a simple, continous form based on a single table.
The records are displayed by order of 'modulecode' - a string of about 5
characters.
I have placed an unbound textbox (txtModuleCodeFilter) in the form header
which I hope to use to type in a couple of characters and have the form
filter to modulecodes starting with those characters.
The code below works fine.
The problem is that after a single keystroke in the textbox the filter
changes but then the whole text in the textbox is highlighted; so the next
keystroke overwrites the previous one!
I need to filter to 2 or 3 characters but to do this I have to keep clicking
the cursor to the end of the textbox before typing the next character.
How can I arrange this so that the user can just type a few characters in
the textbox and have the filter respond immediately to each successive
keystroke?
I hope to avoid the 2-stage: 'Type in the box then click button for filter'
approach.
Here is the code:
Private Sub txtModuleCodeFilter_Change()
Dim L As Integer
Dim CodeSelected As String
CodeSelected = Nz(txtModuleCodeFilter.Text)
'Filter the form to start like the textbox
If CodeSelected = "" Then
Me.FilterOn = False
Else
L = Len(CodeSelected)
Me.Filter = "left(ModuleCode, " & L & ") = '" & CodeSelected & "'"
Me.FilterOn = True
End If
End Sub
Any suggestions gratefully received.
Thanks
Richard