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!!!
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.)
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?
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.
DoCmd.OpenForm "Employees", acNormal
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
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.