By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,667 Members | 2,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,667 IT Pros & Developers. It's quick & easy.

Forms and Form

P: n/a
Hi everyone !

1) An example from help:

"Each Form object has a Controls collection, which contains all
controls on the form. You can refer to a control on a form either
by implicitly or explicitly referring to the Controls collection. Your
code will be faster if you refer to the Controls collection implicitly.
The following examples show two of the ways you might refer
to a control named NewData on the form called OrderForm:

' Implicit reference.
Forms!OrderForm!NewData

' Explicit reference.
Forms!OrderForm.Controls!NewData

The next two examples show how you might refer to a control named NewData on
a subform ctlSubForm contained in the form called OrderForm:

Forms!OrderForm.ctlSubForm.Form!Controls.NewData
Forms!OrderForm.ctlSubForm!NewData"

Why is there a "." character after the name of the main form ? (and
the same with a dot after "Controls" property). It's not a method
or property ... And if you look at other key-word "Form, Report
Properties" there is also an example:

intOrderID = Forms!Orders!OrderDetails.Form!OrderID

And now - there is a "!" - not "." wich is more logical for me.
Why wasn't it this way in the last example ?

And one more thing - I don't understand the meaning of property
"form" - why to refer to itself ? Can't we refer just this way:

Forms!Orders!OrdersDetails!OrderID ???

If we can do that in this way, why to use "form" property ?

Thanks for all answers.

PS. I use MS Access 2000 version 9.0.2812
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
In many cases, the dot and the bang are interchangable.
In other cases, one or the other is required, and the wrong one won't work.
Personally, I don't get too excited about the theoretical underpinnings; I
just use what works.

As for your question about the Form property, that one IS significant.
Forms!Orders!OrderDetails refers to the subform control, which is located on
the form Orders.
This subform control contains a form, which is accessible using its Form
property.
The controls on the subform belong to this form, not to the subform control.
Although I, too, have seen this form in help files:
Forms!OrderForm.ctlSubForm!NewData
I have never been successful in making it work without referring to the Form
property of the subform control.

Pozdrowienia
- Turtle
"Soryt" <di**@wp.pl> wrote in message
news:br**********@atlantis.news.tpi.pl...
Hi everyone !

1) An example from help:

"Each Form object has a Controls collection, which contains all
controls on the form. You can refer to a control on a form either
by implicitly or explicitly referring to the Controls collection. Your
code will be faster if you refer to the Controls collection implicitly.
The following examples show two of the ways you might refer
to a control named NewData on the form called OrderForm:

' Implicit reference.
Forms!OrderForm!NewData

' Explicit reference.
Forms!OrderForm.Controls!NewData

The next two examples show how you might refer to a control named NewData on a subform ctlSubForm contained in the form called OrderForm:

Forms!OrderForm.ctlSubForm.Form!Controls.NewData
Forms!OrderForm.ctlSubForm!NewData"

Why is there a "." character after the name of the main form ? (and
the same with a dot after "Controls" property). It's not a method
or property ... And if you look at other key-word "Form, Report
Properties" there is also an example:

intOrderID = Forms!Orders!OrderDetails.Form!OrderID

And now - there is a "!" - not "." wich is more logical for me.
Why wasn't it this way in the last example ?

And one more thing - I don't understand the meaning of property
"form" - why to refer to itself ? Can't we refer just this way:

Forms!Orders!OrdersDetails!OrderID ???

If we can do that in this way, why to use "form" property ?

Thanks for all answers.

PS. I use MS Access 2000 version 9.0.2812

Nov 12 '05 #2

P: n/a
[...]
The controls on the subform belong to this form, not to the subform control. Although I, too, have seen this form in help files:
Forms!OrderForm.ctlSubForm!NewData
I have never been successful in making it work without referring to the Form property of the subform control.
Does it mean that if I use an expression:

Forms!OrderForm.ctlSubForm!NewData

then I refer to NewData of the main form ?
If it is so, then I get it :D

Thanks for your quick reply.
Pozdrowienia
- Turtle


Również pozdrawiam,
Adrian :)
Nov 12 '05 #3

P: n/a
I have never found the expression
Forms!OrderForm.ctlSubForm!NewData
to be useful for anything.
Forms!OrderForm.ctlSubForm
refers to the subform control;
you can use it to access properties such as Top, Left, which are
common to all controls, as well as specific properties like LinkMasterFields
and LinkChildFields.
In general, these are properties that relate the subform control to
the main form it's sitting on.

Another one of the properties of a subform control is its .Form property.
This is a reference to the form which is contained in the form.
Through this property, you can reference all of the properties of that
form -
including all its controls, its recordset, etc.

To reference the control NewData on the main form, there's no need to make
any reference to the subform control at all -
that would just be
Forms!OrderForm!NewData

HTH
- Turtle
"Soryt" <di**@wp.pl> wrote in message
news:br**********@nemesis.news.tpi.pl...
[...]
The controls on the subform belong to this form, not to the subform

control.
Although I, too, have seen this form in help files:
Forms!OrderForm.ctlSubForm!NewData
I have never been successful in making it work without referring to the

Form
property of the subform control.


Does it mean that if I use an expression:

Forms!OrderForm.ctlSubForm!NewData

then I refer to NewData of the main form ?
If it is so, then I get it :D

Thanks for your quick reply.
Pozdrowienia
- Turtle


Również pozdrawiam,
Adrian :)

Nov 12 '05 #4

P: n/a
[...]
To reference the control NewData on the main form, there's no need to make
any reference to the subform control at all -
that would just be
Forms!OrderForm!NewData


Thank you for your comprehensive answer.

Regards,

Adrian.

PS. I wonder why Forms!OrderForm.ctlSubForm!NewData
works on my computer ... In my opinion Access should throw
an exception, but it doesn't ... :\
Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.