Results 1 to 5 of 5

Thread: Finding Cursor Focus

  1. #1

    Thread Starter
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Question Finding Cursor Focus

    Greetings to All!

    I have a form with 2 combo boxes (CBOEmpNo, CBODeptNo) and few other controls.
    I have a Search Button, that need to search on Emp Number, if CBOEmpNo has a value. Similarly, I am searching on Dept Numbers, if there is a value on CBODeptNo.

    Now, if value exists in both the fields, I need to search based on the position where the cursor is? How do I find in which field the the cursor is located on my form?
    Or is there any other logical way to handle?

    Thanks and Regards,
    Venkat.
    Thanks and Regards,
    Venkat.

  2. #2
    Member
    Join Date
    Apr 2002
    Posts
    42
    pl try using
    screen.ActiveControl

  3. #3

    Thread Starter
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284
    Hi,
    Thanks for the reply.
    My code is like this..But its not solving the purpose.

    If cboBnkId.Text <> "" And Screen.ActiveControl Then

    <Blah..Blah..Blah....>

    ElseIf cboBnkNum.Text <> "" And Screen.ActiveControl Then

    <Blah..Blah..Blah....>

    End If

    Rgds,
    Venkat.
    Thanks and Regards,
    Venkat.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    How about something like

    VB Code:
    1. Private MyControl As Control
    2.  
    3. Private Sub cboEmpNo_GotFocus()
    4. Set MyControl = cboEmpNo
    5. End Sub
    6.  
    7. Private Sub cboDeptNo_GotFocus()
    8. Set MyControl = cboDeptNo
    9. End Sub
    10.  
    11. Private Sub cmdSearch_Click()
    12. If Len(cboEmpNo.Text) > 0 And Len(cboDeptNo.Text) > 0 Then
    13. 'then both have something in them.  use whichever has focus
    14. 'search for MyControl.Text
    15. Else
    16. 'search by which ever one has something in it
    17. End If
    18. End Sub

  5. #5

    Thread Starter
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Cool

    This has worked. Thanks.
    Thanks and Regards,
    Venkat.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width