Best way to Open Form Hidden

  • Thread starter Thread starter tihelles
  • Start date Start date
T

tihelles

I have a frmStartupHidden as Startup form, which is supposed to
open hidden, open a recordset, and then open the Switchboard form and
give it focus/maximized. Code is as follows:

Private Sub Form_Close()
rstAlwaysOpen.Close
Set rstAlwaysOpen = Nothing
End Sub

Private Sub Form_GotFocus()
DoCmd.Restore
Me.Visible = False
End Sub

Private Sub Form_Open(Cancel As Integer)
Set rstAlwaysOpen = CurrentDb.OpenRecordset("tblDummy",
dbOpenSnapshot)
DoCmd.OpenForm ("Switchboard")
End Sub
------
The Switchboard amongst other has the code:
Private Sub Form_Activate()
DoCmd.Maximize
End Sub
------
My current code works, but my forms pop up and down a couple of times
before settling, I guess there must be a better/simpler way to open a form
hidden?
(I am using Acc97, but assume no relevant version changes on this?)

Thor Ivar Hellesoy, Norway
 
Thor,

I suppose the process might be smoother if you do away with the
DoCmd.Restore which I can't see any useful purpose for, and in fact
completely delete the Form_GotFocus code, and change Form_Open to
Private Sub Form_Open(Cancel As Integer)
Me.Visible = False
Set rstAlwaysOpen = CurrentDb.OpenRecordset("tblDummy",
dbOpenSnapshot)
DoCmd.OpenForm ("Switchboard")
End Sub

You could also try using an AutoExec macro to open the Startup form,
where you can specify Hidden in the Window Mode argument of the
OpenForm action.

- Steve Schapel, Microsoft Access MVP
 
Back
Top