Problems with Screen.ActiveControl 
Author Message
 Problems with Screen.ActiveControl

something like:

Private Sub Form_Click()

   If Screen.ActiveControl Is Command1 Then

      MsgBox "Command1"

   End If

   If Screen.ActiveControl Is Command2 Then

      MsgBox "Command2"

   End If

   If Screen.ActiveControl Is Text1 Then

      MsgBox "Text1"

   End If

End Sub

?

--

Randy Birch, MVP Visual Basic

http://www.*-*-*.com/
http://www.*-*-*.com/

Please correspond only using the newsgroups so all can benefit.


| Hi,
|     let's say i have a textbox (text1) and 2 command buttons (edit and
| cancel). Text1 got the Validate event.
| I need to know which control has the focus on a form so i know what to do
| with the validation. In my code, i wanna do something like this
|
| if screen.activecontrol <> "cancel" then
|     do some stuff
| end if
|
| Right now, screen.activecontrol only gets "" as a value...is there some
| alternative to this? Thanks!
|
|



Sat, 26 Jan 2002 03:00:00 GMT  
 Problems with Screen.ActiveControl
Hi,
    let's say i have a textbox (text1) and 2 command buttons (edit and
cancel). Text1 got the Validate event.
I need to know which control has the focus on a form so i know what to do
with the validation. In my code, i wanna do something like this

if screen.activecontrol <> "cancel" then
    do some stuff
end if

Right now, screen.activecontrol only gets "" as a value...is there some
alternative to this? Thanks!



Sun, 27 Jan 2002 03:00:00 GMT  
 Problems with Screen.ActiveControl
Frist of all, you should use the Form's activecontrol property.
Second, the Activecontrol property holds a reference to a Control. Do
the following:

If not Form.ActiveControl is cmdCancel then
    Do your stuff
End if

Replace cmdCancel with the name of your Cancel button

Philipp Keller


Quote:
> Hi,
>     let's say i have a textbox (text1) and 2 command buttons (edit
and
> cancel). Text1 got the Validate event.
> I need to know which control has the focus on a form so i know what
to do
> with the validation. In my code, i wanna do something like this

> if screen.activecontrol <> "cancel" then
>     do some stuff
> end if

> Right now, screen.activecontrol only gets "" as a value...is there
some
> alternative to this? Thanks!



Sun, 27 Jan 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Problems with Screen.ActiveControl

2. Screen.ActiveControl, frm.Recordset

3. Change Backcolor with screen.activecontrol ?

4. What is the .Net equivalent of Screen.ActiveControl

5. UserControl, ContainedControls and Screen.ActiveControl

6. Screen.ActiveControl.SelText???

7. Detect Screen.ActiveControl = Nothing

8. If TypeOf Screen.ActiveControl Is TextBox

9. Screen.ActiveControl.SelText???

10. Activecontrol problem, runtime vs compile time

11. Screen Saver on top of Screen Saver problem

12. activecontrol

 

 
Powered by phpBB® Forum Software