Access App Activation

T

ThesenFamily

I need to refresh a window when returning from another application.
The window that needs refreshing was the active window when I went to
the second app and is still active when I return.
How do I test when the Access Application is activated?
Thanks
 
D

Dale Fye

Access forms have an Activate event which occurs when a form or report
receives the focus and becomes the active window.

You could put some code in this event for your form to cause it to refresh
or requery the forms dataset, but if you requery it, you should first store
the value of the current record you are on, and after the requery, move back
to that record. If it is a data entry form, you might also want to bypass
the requery until after the current record is saved.

HTH
Dale
 
R

Rick Brandt

Dale said:
Access forms have an Activate event which occurs when a form or report
receives the focus and becomes the active window.

Activate and Deactivate do not occur between the Access window and other
application windows. Only when you move amongst windows within Access itself.

I'm not sure there is an event that satisfies thje OP's requirements
 
D

Dale Fye

Rick,

I Could have sworn I tested that before I posted my message. But when I
just did it again, I find that you are absolutely correct. Maybe it was
only working when I moved between objects in the Access window.

I found an API call GetActiveWindow and called it in the forms OnTimer
event. It returned the same numeric value for any form that was active in
the Access window, but returned a zero (0) for every other application I
tested, except the VBA Editor window. All I had to do was declare this
function:

Declare Function GetActiveWindow Lib "user32" () As Long

in a code module and every time the OnTimer event fired for the form, it
returned a numeric value (usually zero, but not in Access or in the VBA Code
Editor window)

So I think this would work in that the timer event could check to see
whether the value returned by GetActiveWindow is the same as the value for
the Access database window. Might need to tweak the timerinterval so that
when the GetActiveWindow returns the value for the Access window, the timer
interval is every minute or so, and as soon as these values differ, it
changes the interval to more frequent (maybe 500). Then just set a flag or
call a specific code segment when the value changes from other than Access
to Access.

Dale
 
T

ThesenFamily

I need to refresh a window when returning from another application.
The window that needs refreshing was the active window when I went to
the second app and is still active when I return.
How do I test when the Access Application is activated?
Thanks

Thanks very much Dale.
I'll try your remedy ...
Have a good weekend.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top