"Marshall Barton" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Vlad wrote:
>
> >I have two forms in my database and one of them is causing me problems
> >as follows in parts of my code. Easier with an example:-
> >
> >If I run this:-
> >
> >Debug.Print "type = " & TypeName(Form_View_Projects_Actions(2))
> >Debug.Print "type = " & TypeName(Form_Form1)
> >
> >I get the results
> >
> >type = CommandButton
> >type = Form_Form1
> >
> >Why does Form_View_Projects_Actions(2) seem to be a CommandButton? and
> >how do I get it to be a form again.
>
>
> What are you tring to do?
>
> Are you aware that the syntax formobject(N) refers to the
> Nth item in the form's Controls collection? Probably not,
> or you wouldn't be asking your question. What did you
> expect it to mean? If the (2) is part of the name of the
> form, then my advice is: since spaces and other
> non-alphanumeric characters in names are a pain and it hurts
> when you do that, don't do it ;-)
>
> Another point. The syntax Form_nameofform actually refers
> to the form's class module, which may not be the same as a
> form being displayed on the screen. Also, that syntax will
> fail on light weight forms that do not have a code module.
>
> To refer to an open form, you should use the syntax
> Forms!nameofform or to refer to any form, open or not, use
> the syntax CurrentProject.AllForms!nameofform
>
> --
> Marsh
> MVP [MS Access]
Thankyou Both so much - I did not realise / forgot about the naming
convention for form objects. I was trying out a number of different ways of
doing the same thing so just named my forms with (2), (3) for ease -
obviously I could use something else.
Ta very much :=)
|