Access XP Popup Form_GotFocus/Form_Activate

Posted on 2007-10-15
Last Modified: 2013-11-28
Access (2k2/XP) Form_GotFocus and Form_Activated are not firing when a form is a popup; but that's what I need. Anyone know a workaround/solution? While I'm here; is this a "bug" or a "design feature", and if so.. why!?

I've a main "continuous" form displaying multiple records. I've a toggle button to load a **popup** window displaying data relevant to the current record on the continuous form, this popup may be multiply instantiated. The toggle button refreshes On_Current, and the relevant popup form is "SetFocus"ed. This all works fine. Now I want to do the reverse...

If I, by mouse, SetFocus on one of the popup forms I want the cursor location on the main continuous form to move to the relevant record. However, Form_GotFocus/Form_Activated are not firing as the forms are popups. I really don't want to change the popup forms to be normal forms if possible, but can anyone suggest a way around the lack of Form_GotFocus/Form_Activated event?

Many thanks in anticipation

Question by:9swampy
    LVL 75

    Expert Comment

    by:DatabaseMX (Joe Anderson - Access MVP)
    Apparently the On Activate Event does not trigger with Popup is True ... I just tried that.  I don't use Activate that often, so I had not noticed this before.

    Here is your workaround:

    Turn off Popup and/or Modal.

    Then use this code to open your form.

    Private Sub Command10_Click()
        DoCmd.OpenForm "YourFormName"
            DoEvents    'VERY IMPORTANT
        Loop Until CurrentProject.AllForms("YourFormName").IsLoaded = False
    End Sub

    Note also ... the Form_GotFocus will only trigger if the form has No controls ... as mentioned in the Help file.

    LVL 2

    Author Comment

    Thanks mx, but unfortunately turning off popup defeats the purpose. I need to be able to allow the users to continue to use real-estate beyond the bounds of the main Access window. I can retrieve "correct" Form_GotFocus & Form_Activate behaviour by simply turning off pop-up and have code that does all the refreshing correctly, but it's the pop-up functionality I'm hoping to retain.
    LVL 75

    Expert Comment

    by:DatabaseMX (Joe Anderson - Access MVP)
    9s .... what I posted sort of emulates Popup/Dialog ....  no additional code will be executed from the calling form until your popup form is closed.

    LVL 2

    Author Comment

    Thanks mx, but unfortunately turning off popup defeats the purpose. I need to be able to allow the users to continue to use *screen-space* beyond the bounds of the main Access window.

    I've just given in for now and forced my users to stay within the Access main window by turning off popup so I get the Form_[De]Activate events back again. They're not happy, I'm not happy, but by no means the first compromise I've had to make in my time!
    LVL 2

    Author Comment

    Noticed additionally that while popup = true if you explicitly reference the main form from the called form and attempt an oMainForm.Dirty = False then SQL Server gets totally locked out and I have to kill the application to get going again. Hmm. Useful.
    LVL 1

    Accepted Solution

    PAQed with points refunded (125)

    EE Admin

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now