Re: ActiveControl in Form View
- From: Marshall Barton <marshbarton@xxxxxxxxxx>
- Date: Mon, 09 Jan 2006 13:40:49 -0600
>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:
>"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
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.
MVP [MS Access]
- Prev by Date: Re: Please help, all of my databases are crashing!
- Next by Date: Re: In the VB IDE, 'if' statements should be bracketed
- Previous by thread: Re: Display Message 'No Data' for a Query
- Next by thread: Update a combo box