Link to home
Start Free TrialLog in
Avatar of 9swampy
9swampyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Access XP Popup Form_GotFocus/Form_Activate

Problem:
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!?

Background:
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

Justin
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

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"
    Do
        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.

mx
Avatar of 9swampy

ASKER

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.
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.

mx
Avatar of 9swampy

ASKER

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!
Avatar of 9swampy

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial