Is there any straightforward way from keeping form_load from being invoked, when refernecing Form.visible?
I was surprized to find out that form_load() gets called if the form was never shown, and I check form.visible.
Printable View
Is there any straightforward way from keeping form_load from being invoked, when refernecing Form.visible?
I was surprized to find out that form_load() gets called if the form was never shown, and I check form.visible.
Hi,
Check for the previous instance of the application.
Thanks
Who said he was calling the app again?
If you don't want code to fire, but it in Form_Activate, but include a flag that checks whether Form_Visible is True before it fires..
I hide forms that I'll need again, but only clear all the variables if a pending calculation isn't needed. The pending calc sets the flag.
If it doesn't need to display a total, _Activate sets the form to all zeroes. If it is a total, then the code doesn't fire.
The first thing I thought of is If Not Form1 Is Nothing Then... but oddly it isn't ever Nothing, even after setting it to Nothing. I've been using Set Form1 = Nothing when I want to get a form to completely release memory, because there have been cases where variables wouldn't return to the default state. Since that seems to work it made sense that the form would be Nothing, but apparently not. So I guess I'm gonna have to reinvestigate that.
Well, I suppose you could have a Boolean for each form in a module that gets set when the form loads and unloads.
If you refer to a Form, then it will be loaded into memory, even if it wasn't.
That causes problems if you try to unload a form, and then refer to it again.
It gets loaded again.
One thing you can do is to browse the forms collection and see if your form is loaded, if it is loaded, then you can check the visible property. Another option would be to create your form with variables, for example, instead of calling "form2.show", you create a variable "private frm2 as form2" for example. That way, you will have more control on the form (you will be able to set it to nothing That way, you can easily set the variable to "nothing" when it is unloaded.
JeffB
Hey Guys !
I think its totally easy in most cases.
do the following
This way you find out if a defined form is loadedCode:Private Function IsLoaded(sFormName as string) as Boolean
Dim oForm as Form
For each oForm in Forms
If oForm.Name = sFormName then
IsLoaded = True
exit Function
End if
Next
End Function
wich is very useful in many cases. If you have more Forms with the same name then you can add them a number property ( or using the Tag Property ) too and checking for that numer also
so its not needed to load a form to check for VisibleCode:Private Function IsLoaded(sFormName as string, lgIndex as long) as Boolean
Dim oForm as Form
For each oForm in Forms
If oForm.Name = sFormName then
If oForm.Tag = lgIndex then
IsLoaded = True
exit Function
End if
End if
Next
End Function
Hope this helpsCode:Private Function IsVisible(sFormName as string) as Boolean
Dim oForm as Form
For each oForm in Forms
If oForm.Name = sFormName then
If oForm.Visible = True then
IsVisible = True
exit Function
End if
End if
Next
End Function
Jonny Poet;)