From: Barry Tank on
I have created a form for filtering a query (txtCustomerName field) by typing
in value. The form has a single text box (unbound or bound to a field hasn't
helped). There is a subform based on a query which returns all records
sorted by customer name. When characters are typed in the text box, the
query is filtered using the following (like "*"&
[Forms]![frmCustomerLookup]![txtLookupName] & "*"). I trap the Change Event
on the control txtCustomerName, refreshing the subform with Me.Refresh after
each change event (It filters exaxtly the way I want it to). Here is my
problem: After each character is entered, all the text is selected, and the
next keystroke replaces all of the text. The user will have to use the right
arrow key (assuming the behavior is set to allow this) or click in the field
after the existing text every time a new character is typed. Is there a way
to enter a Right Arrow Key command after the refresh. Issuing the Refresh
command on the main form is the only way I have successfully filtered the
records after each keystroke, but maybe there is a better way. Additionally,
"spaces" entered get wiped out immediately, which I could live with, but
would like to use them in the filter string as well.
--
Barry
From: Allen Browne on
When the Change event fires, the control's Value has not been updated yet.
So, you need to assign the Value of the control, and then set the SelStart
to the right location.

There's an example in the FindAsUTypeChange() function on this page:
http://allenbrowne.com/AppFindAsUTypeCode.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"Barry Tank" <BarryTank(a)discussions.microsoft.com> wrote in message
news:CA23986B-894F-490B-AA6C-5A17DB765158(a)microsoft.com...
> I have created a form for filtering a query (txtCustomerName field) by
> typing
> in value. The form has a single text box (unbound or bound to a field
> hasn't
> helped). There is a subform based on a query which returns all records
> sorted by customer name. When characters are typed in the text box, the
> query is filtered using the following (like "*"&
> [Forms]![frmCustomerLookup]![txtLookupName] & "*"). I trap the Change
> Event
> on the control txtCustomerName, refreshing the subform with Me.Refresh
> after
> each change event (It filters exaxtly the way I want it to). Here is my
> problem: After each character is entered, all the text is selected, and
> the
> next keystroke replaces all of the text. The user will have to use the
> right
> arrow key (assuming the behavior is set to allow this) or click in the
> field
> after the existing text every time a new character is typed. Is there a
> way
> to enter a Right Arrow Key command after the refresh. Issuing the Refresh
> command on the main form is the only way I have successfully filtered the
> records after each keystroke, but maybe there is a better way.
> Additionally,
> "spaces" entered get wiped out immediately, which I could live with, but
> would like to use them in the filter string as well.
> --
> Barry