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

Differences - Syntax & Form operations

P: n/a
MS
Just a general question here re VBA.

Can anyone explain the differences between "!" and "." when refering to a control?

eg Me!TxtBox and Me.TxtBox.

What is difference between "+" and "&" when working with strings.

eg MyStr = "I have " & MyNumber & " apples." and MyStr = "I have " + MyNumber + " apples."

Also, what are the differences between Loading a form and Opening a form, Similarly with Unload and Close.

From my observations, all the above pairs achieve the same things - I find I can interchange them without noticing any differences. Are there subtle differences, or are they basically the same?

Cheers!

Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bang (!) and dot (.) - basically the same. The exclamation point (bang)
means refer to the collection item. Since Me refers to the form, and
the form's default collection is Controls then Me!TxtBox refers to the
control "TxtBox" in the form's Controls collection.

The period (dot) means refer to the property. A control can also be a
property of the form, so Me.TxtBox refers to the control/property
"txtBox" and also any Field named "txtBox" in the form's Recordsource.

The ampersand (&) is purely a string concatenation operator. The plus
sign (+) is also a concatenation operator that sets the string to NULL
if NULL is the last value. E.g. (debug window):

? null & "this one" + null + " that one"
Null

? null & "this one" & null & " that one"
this one that one

Loading & Opening a form: Opening a form can be cancelled. Loading
can't cancel the opening of the form.

Unload & Close a form: Unload can be cancelled. Closing can't.

The order of events is:

Open: Open -> Load -> ...

Close: Unload -> Deactivate -> Close

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQgrwxIechKqOuFEgEQKBNwCfenAA416mTzhOck3MUR1O+A WkBEQAnRgL
g9AVXzhKnM09otwUeRoUqCYa
=amVt
-----END PGP SIGNATURE-----
MS wrote:
Just a general question here re VBA.

Can anyone explain the differences between "!" and "." when refering to a control?

eg Me!TxtBox and Me.TxtBox.

What is difference between "+" and "&" when working with strings.

eg MyStr = "I have " & MyNumber & " apples." and MyStr = "I have " + MyNumber + " apples."

Also, what are the differences between Loading a form and Opening a form, Similarly with Unload and Close.

From my observations, all the above pairs achieve the same things - I find I can interchange them without noticing any differences. Are there subtle differences, or are they basically the same?

Cheers!

Nov 13 '05 #2

P: n/a
MS

"MGFoster" <me@privacy.com> wrote in message
news:bh*****************@newsread3.news.pas.earthl ink.net...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bang (!) and dot (.) - basically the same. The exclamation point (bang)
means refer to the collection item. Since Me refers to the form, and
the form's default collection is Controls then Me!TxtBox refers to the
control "TxtBox" in the form's Controls collection.

The period (dot) means refer to the property. A control can also be a
property of the form, so Me.TxtBox refers to the control/property
"txtBox" and also any Field named "txtBox" in the form's Recordsource.

The ampersand (&) is purely a string concatenation operator. The plus
sign (+) is also a concatenation operator that sets the string to NULL
if NULL is the last value. E.g. (debug window):

? null & "this one" + null + " that one"
Null

? null & "this one" & null & " that one"
this one that one

Loading & Opening a form: Opening a form can be cancelled. Loading
can't cancel the opening of the form.

Unload & Close a form: Unload can be cancelled. Closing can't.

The order of events is:

Open: Open -> Load -> ...

Close: Unload -> Deactivate -> Close

Thanks! :-)
Nov 13 '05 #3

P: n/a
MGFoster wrote:
The period (dot) means refer to the property. A control can also be a
property of the form, so Me.TxtBox refers to the control/property
"txtBox" and also any Field named "txtBox" in the form's Recordsource.


Steer clear of using a dot for controls/fields, in some versions of
Access in cirtain circumstances it won't compile anyway and there's the
danger that some numpty named a field/control something like "Name" so
that Me.Name is now ambiguous. Doesn't need a numpty either, you can
name something perfectly sensible then MS make that name a keyword in
the next version of Access.

--
This sig left intentionally blank
Nov 13 '05 #4

P: n/a
Trevor Best <no****@besty.org.uk> wrote in
news:42**********************@news.zen.co.uk:
MGFoster wrote:
The period (dot) means refer to the property. A control can
also be a property of the form, so Me.TxtBox refers to the
control/property "txtBox" and also any Field named "txtBox"
in the form's Recordsource.


Steer clear of using a dot for controls/fields, in some
versions of Access in cirtain circumstances it won't compile
anyway and there's the danger that some numpty named a
field/control something like "Name" so that Me.Name is now
ambiguous. Doesn't need a numpty either, you can name
something perfectly sensible then MS make that name a keyword
in the next version of Access.

Even more insidious is a translation. Wrote some code using french
field names: nom, prénom, addresse, téléphone. It worked fine on my
english version of Access '97, but failed with the "nom est un mot
réservé" message when run on my customer's french version of Access
'97. grrrr!

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.