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

bang or dot? How to reference controls in queries?

P: n/a
all this dot and bang syntax is confusing. if anyone can bring clarity to
this subject I would really appreciate it.

Forms![frmMain]![frmSub].Form![ctl_on_Sub] -- to reference a text box on a
subform

But is this the same in a query??

Forms!frmMain!frmSub!ctl_on_Sub -- to reference a textbox on a sub form in a
query

what about nested sub forms?

Forms!frmMain!frmSub!frmNestedSub!ctl_on_NestedSub -- is this correct in a
query?

so you never use a dot in a query? only bangs?
are brackets necessary?

How about referencing the parent?

=Parent![ctl_on_ParentForm]

How about Me???

Me. or Me! ???

Me![frmSub].ctl_on_Sub
--or--
Me![frmSub]![ctl_on_Sub]
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"deko" <dj****@hotmail.com> wrote in
news:Ou********************@newssvr21.news.prodigy .com:
all this dot and bang syntax is confusing. if anyone can
bring clarity to this subject I would really appreciate it.

Microsoft suggested syntax is to use a dot when the word following
it is an Access word and use a bang if it's a programmer defined
word. But Wizard generated code often violates the recommendation.

me.visible
me!txtBox0
me!textBox0.visible
Forms!myForm!mySubform.form!txtBox0.visible

The only place I've had trouble when using the dot is with
set rst0 = x
rst0!fieldname works, rst0.fieldname sometimes gives an error.

Bob Q.
Nov 12 '05 #2

P: n/a
Just out of curiosity, does anyone know the programmatic significance
of this? What goes on behind the scenes?

Bob Quintal <bq******@generation.net> wrote in message news:<3a******************************@news.terane ws.com>...
"deko" <dj****@hotmail.com> wrote in
news:Ou********************@newssvr21.news.prodigy .com:
all this dot and bang syntax is confusing. if anyone can
bring clarity to this subject I would really appreciate it.

Microsoft suggested syntax is to use a dot when the word following
it is an Access word and use a bang if it's a programmer defined
word. But Wizard generated code often violates the recommendation.

me.visible
me!txtBox0
me!textBox0.visible
Forms!myForm!mySubform.form!txtBox0.visible

The only place I've had trouble when using the dot is with
set rst0 = x
rst0!fieldname works, rst0.fieldname sometimes gives an error.

Bob Q.

Nov 12 '05 #3

P: n/a
According to Access2000 Developer's Handbook (pg. 441):

-------------------------------------------
Just remember these rules:

-Dots (".") can only be used to preface properties or methods, not objects
within collections. Access makes a special case for controls on forms (and
reports), so you can use a dot to preface these objects. This can make your
code run a bit faster, if it references these objects

-Bang ("!") turns into parentheses/quotes around an object internally, so
there's little reason to use it. In any case, you use bang or
parentheses/quotes to separate an object from the collection containing that
object.
---------------------------------------------

But Bob's explanation is far more elegant and easier to remember - thanks,
Bob!

BTW, I, too have always been amazed (or amused?) at how often Microsoft
violates its own rules. You read the "theoretical" syntax rules, try and
carefully follow them, then go to the help menu for an example and it's
different - yet sadly works just as well or better!

Guess that's why they pay Access programmers the BIG bucks...

Mike Metzger
"Andante.in.Blue" <05********@sneakemail.com> wrote in message
news:bc**************************@posting.google.c om...
Just out of curiosity, does anyone know the programmatic significance
of this? What goes on behind the scenes?

Bob Quintal <bq******@generation.net> wrote in message

news:<3a******************************@news.terane ws.com>...
"deko" <dj****@hotmail.com> wrote in
news:Ou********************@newssvr21.news.prodigy .com:
all this dot and bang syntax is confusing. if anyone can
bring clarity to this subject I would really appreciate it.

Microsoft suggested syntax is to use a dot when the word following
it is an Access word and use a bang if it's a programmer defined
word. But Wizard generated code often violates the recommendation.

me.visible
me!txtBox0
me!textBox0.visible
Forms!myForm!mySubform.form!txtBox0.visible

The only place I've had trouble when using the dot is with
set rst0 = x
rst0!fieldname works, rst0.fieldname sometimes gives an error.

Bob Q.

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.