Selstart and cursor position

G

Guest

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
 
G

Guest

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
 
G

Guest

Same result i'm afraid - starts at beginning of field before "a" again.

TonyT

Jonathan said:
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


TonyT said:
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
 
J

J. Goddard

Hi -

Can you clarify what it is you are trying to do?
Thanks

john

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
 
G

Guest

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

J. Goddard said:
Hi -

Can you clarify what it is you are trying to do?
Thanks

john

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
 
J

J. Goddard

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



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

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
 
G

Guest

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.

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, 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

J. Goddard said:
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



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
 
J

J. Goddard

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
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])
 
G

Guest

Still the same here!!!

for sake of completeness here is the full coding for the After_Update event
(strPtFilt is a private variable that may or may not have a value set
elsewhere, but makes no odds on this effect regardless);

Private Sub Text34_AfterUpdate()
Dim stractiv As String

If strPtFilt = "" Then strPtFilt = "PtTbl.PtNum LIKE '*'"

If Not IsNull(Me![Text34]) Then
strDesc = Me![Text34]
Else: strDesc = "*"
End If

If Not IsNull(Me![Text39]) Then
Me.Filter = strPtFilt & " AND " & "PtTbl.PtDesc LIKE '*' & '" &
strDesc & "' & '*' AND PtTbl.PtDesc LIKE '*' & '" & strDesc2 & "' & '*'"
Else: Me.Filter = strPtFilt & " AND " & "PtTbl.PtDesc LIKE '*' & '" &
strDesc & "' & '*'"
End If

Me.FilterOn = True

End Sub

my first choice fix would be not to have to double click tab, but selstart
route would be fine if it would work (it was in afterMe.FilterOn = True, but
now is in On_gotFocus - still to no avail)

Thx for time and effort so far - it is appreciated.

TonyT

J. Goddard said:
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
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
 
J

J. Goddard

Hi Tony -

I suggested you put Me![Text34].SelStart = Len(Me![Text34])
in the On Got Focus event of text34.

But only that line - leave

If Not IsNull(Me![Text34]) Then
Me![Text34].SetFocus
End If

where they were, in the after update event.

Try putting some text in text34, and then tab into it from the previous
textbox in the tab order. What happens - does the cursor go where you
want it to?

John
Still the same here!!!

for sake of completeness here is the full coding for the After_Update event
(strPtFilt is a private variable that may or may not have a value set
elsewhere, but makes no odds on this effect regardless);

Private Sub Text34_AfterUpdate()
Dim stractiv As String

If strPtFilt = "" Then strPtFilt = "PtTbl.PtNum LIKE '*'"

If Not IsNull(Me![Text34]) Then
strDesc = Me![Text34]
Else: strDesc = "*"
End If

If Not IsNull(Me![Text39]) Then
Me.Filter = strPtFilt & " AND " & "PtTbl.PtDesc LIKE '*' & '" &
strDesc & "' & '*' AND PtTbl.PtDesc LIKE '*' & '" & strDesc2 & "' & '*'"
Else: Me.Filter = strPtFilt & " AND " & "PtTbl.PtDesc LIKE '*' & '" &
strDesc & "' & '*'"
End If

Me.FilterOn = True

End Sub

my first choice fix would be not to have to double click tab, but selstart
route would be fine if it would work (it was in afterMe.FilterOn = True, but
now is in On_gotFocus - still to no avail)

Thx for time and effort so far - it is appreciated.

TonyT

:

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
 
G

Guest

Replies in order below;

J. Goddard said:
Hi Tony -

I suggested you put Me![Text34].SelStart = Len(Me![Text34])
in the On Got Focus event of text34.

But only that line - leave

If Not IsNull(Me![Text34]) Then
Me![Text34].SetFocus
End If

where they were, in the after update event.

(tried that first) now have exactly as you describe here except with on
error resume next around Me![Text34].SelStart = Len(Me![Text34]) to prevent
null type mismatch errors on first entry. 1st tab atempt doesn't leave field
and cursor appears at beginning of text on typing in text for the first time.
Try putting some text in text34, and then tab into it from the previous
textbox in the tab order. What happens - does the cursor go where you
want it to?

In this scenario, the selstart line works fine - the cursor appears at the
end of the text each time you enter, and tabbing around in all directions is
fine (but then it was anyway, except that previously the whole text was
highlighted which is fine either way)

next suggestion please John!!!!!

TonyT
John
Still the same here!!!

for sake of completeness here is the full coding for the After_Update event
(strPtFilt is a private variable that may or may not have a value set
elsewhere, but makes no odds on this effect regardless);

Private Sub Text34_AfterUpdate()
Dim stractiv As String

If strPtFilt = "" Then strPtFilt = "PtTbl.PtNum LIKE '*'"

If Not IsNull(Me![Text34]) Then
strDesc = Me![Text34]
Else: strDesc = "*"
End If

If Not IsNull(Me![Text39]) Then
Me.Filter = strPtFilt & " AND " & "PtTbl.PtDesc LIKE '*' & '" &
strDesc & "' & '*' AND PtTbl.PtDesc LIKE '*' & '" & strDesc2 & "' & '*'"
Else: Me.Filter = strPtFilt & " AND " & "PtTbl.PtDesc LIKE '*' & '" &
strDesc & "' & '*'"
End If

Me.FilterOn = True

End Sub

my first choice fix would be not to have to double click tab, but selstart
route would be fine if it would work (it was in afterMe.FilterOn = True, but
now is in On_gotFocus - still to no avail)

Thx for time and effort so far - it is appreciated.

TonyT

:

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top