Is Form Loaded check without causing form to load (EASY!)
Check to see if a form is loaded without actually loading the form, or access public form variables without causing the form to load
Original Author: Dave Gallant
Code
Loaded = m_bLoaded End Property ' set the value of the new property m_bLoaded = bLoaded End Property ' set the loaded property to true End Sub Private Sub Form_Unload(Cancel ' set the loaded property to false End Sub Now, form any other form or module, you can do this (assume you are using the If Form1.Loaded = True Then MsgBox "Form is loaded" Else MsgBox "Form is not loaded" End If Form1.show 1, me ' (show my new form give it a shot, let me know if you have any problems.
Ever want to check to see if a form is loaded before you try to access it?
The only way I know of (other than this way) is to loop through the form collection...
a rather large pain in the rear.
The trick is to create a new form property.
Add the following code to any form:
Option Explicit
' Create a new property variable
Dim m_bLoaded
As Boolean
' get the value of the new property
Public Property Get Loaded()
As Boolean
Public Property Let Loaded(ByVal
bLoaded As Boolean)
Private Sub Form_Load()
Me.Loaded = True
As Integer)
Me.Loaded = False
default form name)
Accessing this property will not cause the form to load in the event that loaded
is false.
However, if you make a single variable and make it public on the form, and try
to access it, the form will load.
You can actually use this property method to retain any data and access it without
reloading hte form.
I created a custom input box field in which the "Return String" is
a custom property, like the loaded property.
then I just do this:
modal)
strInput = Form1.strInput '(this
will not cause the form to reload provided your property is called strInput!)
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.