What is the opposite of SetFocus?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have posted this question on the other thread last week, but I am still
have trouble with the issue.

Basically, after the subform got populated, I had one text field from the
main form and one from the sub highlighted, but it is the one on the main
form got the focus. I want it to lost the focus, or give it to sub form.

But how? Selected=false? txt.UnSetFocus?

The tab stop and tab index seems only cycle within controls on the
header/main form, or on the detail/subform, but not jump across from one to
the other.

Here are the controls I have:
txtHeader1 and cmdHeader1 are on the header, and txtDetail1 is on the
subform, which is located in the detail section.

Users type a value in txtHeader1, then click cmdHeader1 to populate
txtDetail1.
Now, at this time, both values in txtHeader1 and txtDetail1 got highlighted.
The new input will be in txtHeader1. I want only txtDetail1 to have the
focus, and take the input.

Am I asking too much? Thanks!
 
homer said:
I have posted this question on the other thread last week, but I am still
have trouble with the issue.

Basically, after the subform got populated, I had one text field from the
main form and one from the sub highlighted, but it is the one on the main
form got the focus. I want it to lost the focus, or give it to sub form.

But how? Selected=false? txt.UnSetFocus?

The tab stop and tab index seems only cycle within controls on the
header/main form, or on the detail/subform, but not jump across from one to
the other.

Here are the controls I have:
txtHeader1 and cmdHeader1 are on the header, and txtDetail1 is on the
subform, which is located in the detail section.

Users type a value in txtHeader1, then click cmdHeader1 to populate
txtDetail1.
Now, at this time, both values in txtHeader1 and txtDetail1 got highlighted.
The new input will be in txtHeader1. I want only txtDetail1 to have the
focus, and take the input.

Am I asking too much? Thanks!


You may be asking too much. Each form object (with a
control that can receive the focus) will have an active
control. Maybe you just need to set that focus to some
other control??
 
Thank you Marshall and Tim,

I did have a line of code that reads:
Me![subPOItem].Form.[# of Labels].SetFocus
I steped through it without any error.

However, my txtbox in main form still retains the focus somehow, because not
only it is highlighted, but also the new input went into there. So that is
why I try to "de-focus" it, and move the focus into subform.
 
If you want to automatically shift the focus, just set the focus to
another control. There is no UnFocus.
 
Try using two steps :

'Air Code

'1. Set the focus to the subform control on the main form.
' This should take the selection off of the original field.
Me![subPOItem].SetFocus

'2. Then, set the focus to the control of the subform.
Me![subPOItem].Form.[# of Labels].SetFocus

You can use this in txtHeader1's LostFocus event. Alternatively, you can
add a dummy textbox to the header. Call it txtDummy. Size its width to
0 and make sure it is transparent with no border. It must have
visible=true, but the width makes it effectively invisible.Put its tab
order right after txtHeader1. Create a GotFocus event and add the above
code.
The nice thing about this dummy textbox is that it allows you to
shift-tab or click away from txtHeader without re-directing you to the #
of Labels control (since both of these actions would fire txtHeader's
LostFocus but not txtDummy's GotFocus)

Stay in focus!

HTH,
Kevin
Thank you Marshall and Tim,

I did have a line of code that reads:
Me![subPOItem].Form.[# of Labels].SetFocus
I steped through it without any error.

However, my txtbox in main form still retains the focus somehow, because not
only it is highlighted, but also the new input went into there. So that is
why I try to "de-focus" it, and move the focus into subform.

:

Just SetFocus somewhere else. The focus can't be nowhere, so you will have
to send it somewhere.

Tim F
 
Back
Top