Hi James,
I've just done some testing, and I agree - this is rather tricky. There is,
as you say, no OnRestore event, and there is also no direct way of referring
to the database window - you have to select something within that window to
cause it to become active.
I tried the Activate event, and got the minimize/restore cycling (until it
times out). So that's a no-go.
However, I did get this to work, using the form's resize event, and testing
the form's height to determine whether it is minimized.
Private Sub Form_Resize()
If Me.WindowHeight <> 465 Then 'Height of minimized window
'Select and minimize database window
DoCmd.SelectObject acTable, , True
DoCmd.Minimize
Else
'Select and restore database window
DoCmd.SelectObject acTable, , True
DoCmd.Restore
End If
End Sub
Maybe that will suffice for what you want. If your form is sizeable, the
code also runs when you resize the form; it also runs if you maximize the
form; in both cases, there's a switch of focus to the database window (in
the second case it maximizes and then minimizes), but there's no cycling of
windows.
HTH,
Rob