RE: Setfocus to a textbox



I am gald you got it sorted out. Well done.

Just a point - if you write some code it is always worth spending a few
moments working why it works (or doesn't) as it is never a good idea to just
tap the keyboard and see what happens as 1 bit of code will sometimes affect
others. So well done again but have a look at the code you have written and
try and work it out.


--
Wayne
Manchester, England.
Enjoy whatever it is you do


"Marcus Lloyd" wrote:

Ive added a little bit of code to help, it seemed to work. What I do is the
following:

Clear the txtLPN:

txtLPN.SetFocus
txtLPN.Text = ""

SetFocus to txtCurrentASN

txtCurrentASN.SetFocus

SetFocus to txtLPN

txtLPN.SetFocus

BINGO - It worked, why, I don't know

"Marcus Lloyd" wrote:

What I have is the following:

FRM_ASN_HDR - Main Form
FRM_ASN_DET- Sub Form
txtCurrentASN - Textox on the Main Form
txtLPN - Textbox on the Main Form

What happens:

Input data into txtLPN

The data is confirm and updates the FlexGrid

This is done by the On_Exit Event from txtLPN.

The subform is linked to txtCurrentASN by Master/Child feilds. This is good
because as the value in txtCurrentASN changes the subform's data updates.

But, when the On_Exit event is triggered for txtLPNthe last bit of code is:

Me.txtLPN.SetFocus

But, the focus is returned to txtCurrentASN.

I've read an earlier post by yourself showing how to setfocus to a subform's
control, but this is not what i'm trying to do. I think that an event is
triggering after the On_Exit event of the textbox?

"Wayne-I-M" wrote:

Hi

You did not mention a subform in your post ?

If you want to set the focus to a field on a subform from a main form you
have to do this in 2 stages.

1st set the focus to the sub form
2nd set the focus to the field

If you can let me know some details - where are you trying to "fire" the
event from. name of the main form, name of the sub form, etc. I can send
back the code.

I may have misunderstood but I think you are trying to do "something" on a
main form that will clear the details (check box) om a subform - hope this is
right.

--
Wayne
Manchester, England.
Enjoy whatever it is you do


"Marcus Lloyd" wrote:

By adding 'Me', the same fault happens.

But I think its to do with a linked subform updating from a textbox after
the OnExit event has completed. Can't find an event for after the subform
updates, tried AfterUpdate but it does not trigger?

"Wayne-I-M" wrote:

Hi Marcus

txtLPN.SetFocus
txtLPN.Text = ""

Should be

Me.txtLPN.SetFocus
Me.txtLPN =" "


Hope this helps
--
Wayne
Manchester, England.
Enjoy whatever it is you do


"Marcus Lloyd" wrote:

Hi,

I have a form that has a textbox, subform, and a MSFlexGrid.

On Exit from the textbox I have code that adds the records to the flexgrid
after some processing, opening connections and recordsets to the DB.

At the end of the code the last thing the code does is to clear down the
textbox and sets the focus to it.

txtLPN.SetFocus
txtLPN.Text = ""
txtLPN.SetFocus

After the code executes the SetFocus method is called but the focus does not
set to the textbox.

I've also tried using DoCmd.GoToControl "txtLPN", but still the focus is not
on the textbox control.

Any ideas?


.



Relevant Pages

  • RE: Setfocus to a textbox
    ... You have a text box that you enter data (txtLPN) which is on your mai form ... The subform is linked to txtCurrentASN by Master/Child feilds. ... triggering after the On_Exit event of the textbox? ...
    (microsoft.public.access.forms)
  • RE: Setfocus to a textbox
    ... txtLPN - Textbox on the Main Form ... The subform is linked to txtCurrentASN by Master/Child feilds. ... triggering after the On_Exit event of the textbox? ...
    (microsoft.public.access.forms)
  • RE: Setfocus to a textbox
    ... SetFocus to txtCurrentASN ... SetFocus to txtLPN ... The subform is linked to txtCurrentASN by Master/Child feilds. ... triggering after the On_Exit event of the textbox? ...
    (microsoft.public.access.forms)
  • Re: refresh an open form using records from another open form?
    ... Yes, I made the linking textbox visible, and yes the record ID's match ... It's as if the subform only wakes up when I click on it?... ... I click a control on the 'frm_Road_Junctions' form. ... Did you set up the master/child link for the subform control containing ...
    (microsoft.public.access.formscoding)
  • Re: refresh an open form using records from another open form?
    ... Are you saying that you see the value in the textbox changing, ... It's as if the subform only wakes up when I click on it?... ... I click a control on the 'frm_Road_Junctions' form. ... Did you set up the master/child link for the subform control ...
    (microsoft.public.access.formscoding)