On Tue, 17 Jan 2006 20:55:02 -0700, Tom van Stiphout <no*************@cox.net> wrote:
On Wed, 18 Jan 2006 01:46:34 GMT, Wayne Gillespie
<be*****@NOhotmailSPAM.com.au> wrote:
Not sure that bracketing the control name helps. Note that the example
of bad coding in the KB article uses brackets as well:
If Me.Parent![CheckBox] Then
I originally responded because I noticed Wayne had doubled-up on a
control name and had a typo, and wasn't sure the OP would understand
how to correct it. When I rewrote the expression I wrote it the way
I'm used to, knowing about that bug referenced in the KB article. I
also like that way better because it's a bit easier to read for most
developers. Some habits die hard.
-Tom.
The entire reference to the checkbox had to bracketed, not just the control name.
IOW
If (Me.Parent![CheckBox]) Then
instead of
If Me.Parent![CheckBox] Then
The parens force a value to be returned rather than a reference to the control.
The following post by Ken Getz explains further.
Ken Getz
Feb 2 2000, 3:00 am
Newsgroups: comp.databases.ms-access
From: Ken Getz <keng...@my-deja.com>
Date: 2000/02/02
Subject: Re: Are Litwin, Getz and Gilbert not right?
Well, since I wrote that chunk, I'll respond here. No, I
wasn't "wrong", just unfortunate. Because what I didn't know when
writing that was that if you use expressions like
If Me.chkActive Then
in your code, you're leaving a reference open, and Access may not be
able to quit. The solution is to pass a VALUE, not a reference to the
If...Then statement, so there are several solutions:
* If (Me.chkActive) Then
* If Me.chkActive.Value Then (my personal favorite)
* If Me.chkActive = True Then (my personal least favorite)
They all do the same thing -- send a value to the If...Then statement,
so there's no reference to a control left dangling.
So, in theory, the advice in the book is right. Just in this one
instance, Access got in the way.
-- Ken
Wayne Gillespie
Gosford NSW Australia