On Oct 4, 2006, at 1:03 PM, John J. Mihaljevic wrote:
What are you trying to validate? If you just want to
tap into the checkbox losing focus, perhaps the LostFocus()
event will do?
I'm enabling or disabling several textboxes on the form depending
on the
value of the checkbox. Here's a chunk of the Valid code:
if thisform.pageframe1.page1.chkfinished.value=.t.
thisform.pageframe1.page1.txtpartnumber.enabled=.t.
thisform.pageframe1.page1.txtdiameter.enabled=.f.
else
thisform.pageframe1.page1.txtpartnumber.enabled=.f.
thisform.pageframe1.page1.txtdiameter.enabled=.t.
endi
If I physically click the checkbox (chkfinished), the code
executes. When
the box is checked, txtpartnumber is enabled and txtdiameter is
disabled.
And when the box is unchecked, txtpartnumber is disabled and
txtdiameter is
enabled. But when just tabbing across the field (not changing it by
clicking on it or tapping the space bar), the code doesn't execute.
I've tried this code in both the Valid method and the LostFocus
method.
The Enabled state shouldn't change when the checkbox doesn't change,
so why do you need the code to fire?
Also, sorry for being nitpicky, but seeing the code you wrote
brought back many bad memories of code that was broken due to really
long references like you had. Here's one way to accomplish the same
thing with a lot less chance of breakage:
pg = Thisform.pageframe1.page1
finished = pg.chkFinished.Value
pg.txtpartnumber.Enabled = val
pg.txtdiameter.Enabled = not val
This is far from ideal, since it requires a checkbox to know your
business logic, but if you are putting all your code in the form,
it's a big improvement.
-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.