Hi Tony -
See below for double-tab press explanation.
Try putting Me![Text34].SelStart = Len(Me![Text34])
in the On Got Focus event of text34. I put it there, and it works fine.
Hope they help (this time!)
John
TonyT wrote:
No I'm afraid it doesn't
yes the code is in the After_Update event of text34. If I don't have
me![text34].setfocus the focus still remains within Text34 despite there
being 4 other controls which can have the focus - you just have to press tab
twice to exit Text34 for some reason.
Yes. The first tab triggers the After Update event, which keeps the
focus (i.e. cursor) in text34. The second Tab press does not trigger
the After Update event, so the cursor then will move as expected.
The reason for the Text34.setfocus code is to then allow the selstart code
to place the cursor at the end of the text within Text34, as this would be
acceptable if the focus refuses to move normally, and I use it elsewhere to
update filters based on the On_Change event of other textboxes.
I just cannot figure out why the cursor appears at the start of the field
and also why the focus won't move out without double pressing tab,
see above explanation for double tab.
there is
no coding for any formatting of any controls or tab orders etc anywhere on
the form. - 2 command buttons and 3 text boxes all tab stop enabled and
sequenced.
TonyT
:
The code you posted - it is in the After update of what - Text34? If
that's where the code is, the cursor doesn't move because you put it
back in text34 with Me![Text34].SetFocus. If you then press tab without
making any more changes to text34, the cursor should move to the next
text box, provided there is one with tab stop set to "Yes". If text34
is the only textbox with Tab Stop = Yes, pressing tab will not move the
cursor.
Does this help?
John
TonyT wrote:
I am trying to prevent the cursor from appearing at the beginning of the
field 'text34' after pressing tab (having just typed 'air' for example) which
fires the after_update code to filter the data in a continuos form. It seems
that no matter what I try the focus always returns to the same field with the
cursor at the beginning of it, rather than the next textbox.
All the filter code works correctly (filtering data dependant on 3 text
boxes), but getting out of the field or getting to the end of it to edit it
is causing me problems.
To try and understand the sequence of events during the filter coding I find
that the focus leaves and then immediately returns to the said text34 textbox
at the point that me.filter = blah blah blah is executed, but from that point
on the focus remains constantly on text34, but won't allow me to manipulate
the cursor position.
The only other solution I can think of is to go down the tedious route
capturing keystrokes for tab, shift+tab etc etc to try to force the focus
move instead, but I'm sure there is another route.
Hope this clarifies the problem a little better, if not perhaps you can ask
a more specific question.
many thanks,
TonyT
:
Hi -
Can you clarify what it is you are trying to do?
Thanks
john
TonyT wrote:
Same result i'm afraid - starts at beginning of field before "a" again.
TonyT
:
Hi, try the following...
If Not IsNull(Me![Text34]) Then
Me![Text34].SetFocus
Me![Text34].SelStart = 0
Me![Text34].sellength=Len(Me![Text34])
End If
--
Luck
Jonathan Parminter
:
he following code is at the end of After_Update coding that filters a
continuous forms data via the textbox in the form header;
If Not IsNull(Me![Text34]) Then
Me![Text34].SetFocus
Me![Text34].SelStart = Len(Me![Text34])
End If
for example if the search is for "air" the coding correctly has the len as
3, but the cursor always appears at the start of the field before the "a"
despite access being set to select entire field on enter, I wouldn't mind if
the sursor left the field entirely and the focus fell on the next textbox,
but that doesn't happen with or without this code,
what am I doing wrong?
TonyT