Share via

screen.activeform issue when stepping into vba

Anonymous
2016-03-21T19:49:00+00:00

When I am trying to troubleshoot vba procedures and it hits a screen.activeform.control name, I get the error "You entered an expression that requires a form to be the active window."

How can I F8 past this, and still have it gather the required info from the screen.activeform.controlname statement?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

8 answers

Sort by: Most helpful
  1. DBG 11,711 Reputation points Volunteer Moderator
    2016-03-21T20:41:58+00:00

    Actually Don is correct. The VBA editor window does not mess up the Screen.ActiveForm. In the OP's case maybe no form has the focus.

    Hi Tom. That's good to know. Thanks!

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2016-03-21T20:29:40+00:00

    Ciao,

    it seems you are in debug mode. Move the breakpoint after the statement.

    Mimmo

    Was this answer helpful?

    0 comments No comments
  3. Tom van Stiphout 40,211 Reputation points MVP Volunteer Moderator
    2016-03-21T20:25:01+00:00

    Actually Don is correct. The VBA editor window does not mess up the Screen.ActiveForm. In the OP's case maybe no form has the focus.

    Was this answer helpful?

    0 comments No comments
  4. DBG 11,711 Reputation points Volunteer Moderator
    2016-03-21T20:11:44+00:00

    Hi Karen. Screen.ActiveForm relies on a form having the focus. So, since you have forced the VBA IDE to have the focus, I guess Screen.ActiveForm wouldn't know which form should have the focus instead. Would you have any other way of determining the form you need other than using Screen.ActiveForm?

    Was this answer helpful?

    0 comments No comments
  5. Anonymous
    2016-03-21T20:10:57+00:00

    Hmmm, Is the form in form view or design view?

    ?screen.ActiveForm.ActiveControl works for me and returns the correct value in the Immediate Window, as long as the form is in Form View. (It's *so* nice to have dual monitors for this.)

    Was this answer helpful?

    0 comments No comments