Update Data as MDB window looses focus

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Access 2000
Two windows with MDBs loaded accessing the same data recor
Need to refresh the data as one window looses focus so that the same record can be manipulated from the other window

Thanks in advance,
 
Look up the Forms Refresh method.

i.e.

Me.Refresh - enter in the forms Lost Focus Event

HTH

--

Cheers
Mark

Free Access/Office Add-Ins at:
http://mphillipson.users.btopenworld.com/


RobGMiller said:
Access 2000,
Two windows with MDBs loaded accessing the same data record
Need to refresh the data as one window looses focus so that the same
record can be manipulated from the other window.
 
Thanks for the repl

That's the first thing I tried. Unfortunately, the OnLostfocus or OnDeactivate events do not fire when moving off the form or the database for that matter. The OnDeactivage event only fires when the database is closed

Any idea what will make the OnLostFocus event fire?
 
I think the problem is that the lost focus is only applicable to within the
one instance of Access.

One option that comes to mind would be to change the default refresh rate on
the forms load event and set back to normal when the form is closed.

i.e.

'Set a form level variable to store the Current Refresh
Dim intInterval As Integer

Private Sub Form_Load()
'Store refresh interval
intInterval = GetOption("Refresh Interval (sec)")
'Set to 1 second
Application.SetOption "Refresh Interval (sec)", 1
End Sub

Private Sub Form_Close()
'Restore to original setting
Application.SetOption "Refresh Interval (sec)", intInterval
End Sub

There may be a performance issue here because Access is forced to refresh
the form every second!

HTH
Mark.

RobGMiller said:
Thanks for the reply

That's the first thing I tried. Unfortunately, the OnLostfocus or
OnDeactivate events do not fire when moving off the form or the database for
that matter. The OnDeactivage event only fires when the database is closed.
 
Mark said:
I think the problem is that the lost focus is only applicable to
within the one instance of Access.

One option that comes to mind would be to change the default refresh
rate on the forms load event and set back to normal when the form is
closed.

i.e.

'Set a form level variable to store the Current Refresh
Dim intInterval As Integer

Private Sub Form_Load()
'Store refresh interval
intInterval = GetOption("Refresh Interval (sec)")
'Set to 1 second
Application.SetOption "Refresh Interval (sec)", 1
End Sub

Private Sub Form_Close()
'Restore to original setting
Application.SetOption "Refresh Interval (sec)", intInterval
End Sub

There may be a performance issue here because Access is forced to
refresh the form every second!

I don't believe that the automatic form refresh controlled by the
Refresh Interval setting will cause the saving of a dirty record. A
quick test appears to confirm this. I suspect that doing what
RobGMiller is asking will require using API calls to hook the Access
application window and trap a particular window message. This is not an
area I know much about, unfortunately.

It seems to me that it should be possible for the Access instance that
is receiving the focus (call it "instance A") to automate the other
Access instance ("instance B") and instruct it to save the record.
Instance A wouldn't necessarily need to know whether it has just
received the focus, but it might know when it is about to do something
that will require instance B to have saved the record, and so it could
go ahead and tell B to do so.
 
Back
Top