RC- said:
What the difference between
DoCmd.OpenForm "[My Badly Named Form]"
and
FORM_Some_Form_Name.Visble = True
You as a rule DO NOT want to use the 2nd syntax. There is a big difference,
as the 2nd syntax actually refers directly to the object that the ms-access
development system creates (in your example..this is would be a form with
code. If your form has no code, then you can't use the 2nd syntax). So this
class object with code is created by ms-access. So, what happens if the form
is opened two times? Or, even worse, the form is being used as a sub-form in
MORE then one form! (you have no way of know what running copy the above
refers to).
Even worse then the above problems is that if the form is NOT loaded, then
in fact your 2nd syntax will cause the form to load. However, if you now set
the form to
FORM_SomForm.Visible = False
Then, the form is still loaded, and next time when you go:
FROM_SomeForm.Visible = True
In the above, the form will display, but the on-open, and on-load events
(two very important events used for very different things) do NOT fire. As a
developer looking at the above, I have no clue if the form was already
opened, or not. (so, it makes it VERY hard to figure out what the original
developer was trying to do. Was the form already opened...but not visible?).
Worse, is that using the 2nd syntax also does NOT add the loaded form to the
Forms() collection.
Thus,
Forms.Count
Will not return he correct number of forms open. And, you can't use the
following syntax either:
strFormName = inputbox("Show last name from what form?")
msgbox forms(strFormName)("LastName")
Since your forms collection is not set correctly, then again the above code
will NOT work. So, there is a ton of problems, ton of inconsistencies, and
generally just lack of control when events fire. So, use the first
syntax....
In fact, in access 97, you could use the base clase object without creating
a new instance. In a2000 and later, you have to either define a global
var...but you can't use the base instance of custom class ojbects....and
likey the ONLY reason why you can refence the base class object when it
comes to a form is not to break old code.