Results 1 to 6 of 6

Thread: Preload form

  1. #1
    Join Date
    Feb 2005

    Unanswered: Preload form

    This is going to seem like a stupid question i know but bear with me...

    I need to preload a form in an access project because the form takes a while to load and is basically open the entire time that the program is open anyways so i'd rather it just start opened but not visible basically. I can't seem to find the property to just set it to invisible to begin with, don't know why. don't know if thats just not an option with a form or what? i don't want to load the form and then make it invisible because i don't want to see it flash or pop up before it finally goes invisible. I can't remember the code to do this, i just want it pre-loaded!!!

    Thanks in advance

  2. #2
    Join Date
    Feb 2005
    Blacksburg, Virginia
    In the Form_Load Event, you can set the form's Visible Property to False, so you can't see it. The Form_Load event happens before the Form_Open Event, so you won't see any flickering or flashing on the screen.

    Also, you can put some kind of checking code in the Form_Open Event where if some conditions aren't true, then set the argument Cancel to any value other than zero (Cancel = True is a clean way to go about it). This will cancel the open event, so you never see it. The form is loaded however. (This only occurs once.)

  3. #3
    Join Date
    Feb 2005
    That didn't seem to work, i still get that flash of the screen. i told my splash screen to open the form and on form load i put the form.visible to false and still saw the flash. then i tried it the opposite way and put visible to false on form open and still got the same effect. any other ideas?

  4. #4
    Join Date
    Oct 2003
    I agree with Lint Diggy's suggestion on this. I cannot see any other way, however I believe that the On Open event runs BEFORE a form is opened whilst the On Load events run WHEN a form is opened.

    Try the code on your form

    Private Sub Form_Open()


    End Sub

  5. #5
    Join Date
    Feb 2004
    Have a look at the Echo method.
    The following was taken straight out of the VBA help files.

    The following example uses the Echo method to prevent the screen from being repainted while certain operations are underway. While the procedure opens a form and minimizes it, the user only sees an hourglass icon indicating that processing is taking place, and the screen isn't repainted. When this task is completed, the hourglass changes back to a pointer and screen repainting is turned back on.

    Public Sub EchoOff()

    ' Open the Employees form minimized.
    Application.Echo False
    DoCmd.Hourglass True
    DoCmd.OpenForm "Employees", acNormal
    Application.Echo True
    DoCmd.Hourglass False

    End Sub

  6. #6
    Join Date
    Nov 2003
    There are a number of ways of opening a form and keep it invisible. The easiest way is to use Docmd.OpenForm and set the WindowMode option to Hidden. You need to set the hourglass on so the user knows that something is happening whilst the form is opening.

    You could also assign the form to a variable, possibly at the global level. You would use code along the lines of:

    Public mfrmMyForm As Form_MyForm

    ' In a subroutine/function that opens the form
    Public Sub OpenMyForm()
    ' This line opens the form as a hidden form
    Set mfrmMyForm = New Form_MyForm
    ' you can then use any of the forms properties. So to make the form visible you would use:
    mfrmMyForm.Visible = True
    End Sub

    You should also have a look at the form itself and see why it is slow to open. Do you have too many combo boxes/list boxes on the form. These can slow the form down. Are you opening the form and connecting to all the records - if you are then why not open the form with a recordset of one record? The user can then query the form to the record they want.

    I hope this helps

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts