Screen.ActiveControl - error 91 - object variable or with block not set

  • Thread starter Thread starter Stapes
  • Start date Start date
S

Stapes

Hi

I am trying to run the following code & am getting the error message
shown above. The code is triggered by entering a value in any field on
my screen.

Private Function UpdateTariff()
On Error GoTo Err_UpdateTariff
Dim ctl As Control
Dim strControlName As String
ctl = Screen.ActiveControl
strControlName = ctl.Name
MsgBox strControlName
Exit_UpdateTariff:
Exit Function
Err_UpdateTariff:
MsgBox Err.Number & " " & Err.Description
Resume Exit_UpdateTariff
End Function

Any idea why it is not working?

Stapes
 
hi Stapes,
I am trying to run the following code & am getting the error message
shown above. The code is triggered by entering a value in any field on
my screen.

Private Function UpdateTariff()
On Error GoTo Err_UpdateTariff
Dim ctl As Control
Dim strControlName As String
ctl = Screen.ActiveControl
Try

If Not ctl Is Nothing Then
strControlName = ctl.Name
MsgBox strControlName
End If



mfG
--> stefan <--
 
hi Stapes,



Try

If Not ctl Is Nothing Then> strControlName = ctl.Name

End If

mfG
--> stefan <--

Hi Stefan
It does not get that far. The error occurs on the command:

ctl = Screen.ActiveControl

Stapes
 
hi Stapes,
It does not get that far. The error occurs on the command:

ctl = Screen.ActiveControl
Then put the If before that line. The error is normally caused when
Screen.ActiveControl does not point to any control.


mfG
--> stefan <--
 
hi Stapes,



Then put the If before that line. The error is normally caused when
Screen.ActiveControl does not point to any control.

mfG
--> stefan <--

No - that doesn't make any sense. If the field ctl has not been primed
- then it won't have anything there.
 
No - that doesn't make any sense. If the field ctl has not been primed
- then it won't have anything there.

Hi

I found my error - I omitted to put 'Set' before ctl =
Screen.ActiveControl

Stapes
 
Back
Top