Re: ActiveControl in Form View



Leif wrote:

>I have a form with a checkbox control and a text field. If the checkbox
>control is not checked then I want the text field disabled (enabled = false).
>
>This is being done in the form_current event. It works fine in form view,
>since in moving between records in form view the focus is always set to the
>first field when the record is changed.
>
>However, in datasheet view if the user checks on the field to be disabled,
>on a differnt record, then I get the error message that a field that has
>focus cannot be disabled (which makes sense).
>
>To overcome this problem I tried adding code to my form_current event to
>detect if the current control is the one I'm trying to disable. This works
>fine in datasheet sheet, however in form view I get the message:
>
>Error 2474
>
>"The expression you entered requires the control to be in the active window"
>
>The offending code is:
>
> If Screen.ActiveControl.Name = "DDWO" Then PMTNumber.SetFocus '
>Change focus if necessary
>
>
>My question is why does Access think the window is not active? It appears
>to be active to me, and the code presents no problems in datasheet view, only
>form view when I change the record. Is ActiveControl not available in the
>form_current event?

The Screen object refers to the entire Access window where
all kinds of things, including any open form may be
"active". Try using Me.ActiveControl.Name instead.

--
Marsh
MVP [MS Access]
.