469,082 Members | 1,258 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,082 developers. It's quick & easy.

How do I know....

....which control has focus at a given moment?

This is what I want. I have two textboxes in a form: one for vendor
and one for items. Now, if am at the vendor field and I press [F3]
the vendor search form should appear but If I am at the item field It
should show the item search form.
All comments will be appreciated.
Thank you.

Lizard King.
Jul 17 '05 #1
3 2465

"Lizard King" <wi*******@starmedia.com> wrote in message
news:df**************************@posting.google.c om...
...which control has focus at a given moment?

This is what I want. I have two textboxes in a form: one for vendor
and one for items. Now, if am at the vendor field and I press [F3]
the vendor search form should appear but If I am at the item field It
should show the item search form.
All comments will be appreciated.
Thank you.

Lizard King.


Well, the keyevent that will be triggered will be whereever the focus
happens to be.. for example, assuming you have text1 and text2 textboxes, if
you get into the routine below..

Private Sub Text2_KeyPress(KeyAscii As Integer)
' this means soemone press a key when the focus is in text2
'if KeyAscii = 13 then 'someone press ENTER
End Sub
Jul 17 '05 #2
Me.ActiveControl

On 22 Aug 2003 08:06:40 -0700, wi*******@starmedia.com (Lizard King)
wrote:
...which control has focus at a given moment?

This is what I want. I have two textboxes in a form: one for vendor
and one for items. Now, if am at the vendor field and I press [F3]
the vendor search form should appear but If I am at the item field It
should show the item search form.
All comments will be appreciated.
Thank you.

Lizard King.


Jul 17 '05 #3
assuming your texboxes are named txtVendor and txtItem

1. set the form's key preview to True.
2. in the form's key down event. add something like:

If Me.ActiveControl.Name = txtVendor Then
' Code to execute for the On Vendor Situation
ElseIf Me.ActiveControl.Name = txtItem Then
' Code to Execute for the On Item textbox situation
Else
' Probably wont need an Else in this construct.
End if

You just need to add ElseIf construct with its' corresponding code for any
other control you might want to add a search feature to.

--
Stéphane Richard
Senior Software and Technology Supervisor
http://www.totalweb-inc.com
For all your hosting and related needs

"Lizard King" <wi*******@starmedia.com> wrote in message
news:df**************************@posting.google.c om...
...which control has focus at a given moment?

This is what I want. I have two textboxes in a form: one for vendor
and one for items. Now, if am at the vendor field and I press [F3]
the vendor search form should appear but If I am at the item field It
should show the item search form.
All comments will be appreciated.
Thank you.

Lizard King.

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

41 posts views Thread by Nitin Bhardwaj | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.