In an attempt to make an optiongroup handle a logical controlsource,
I made a custom option group class based on the standard
optiongroup class. It has the standard two option buttons.
The only customization is the addition of the following
access and assign methods for the Value property:
Value_Access:
WAIT window "Accessing: "+TRANSFORM(THIS.Value) TIMEOUT 1
RETURN IIF(THIS.Value = 1, .T., .F.)
Value_Assign:
wait window "Assigning: "+TRANSFORM(m.vNewVal) TIMEOUT 1
This.Value = IIF(m.vNewVal = .T., 1, 2)
The ControlSource of the optiongroup is set to a logical field
in a table:
theField
--------
T
F
T
F
T
When the form starts up the wait window with "Assigning .T."
is displayed about 4 times - apparently during the form's
paint and refresh methods.
Okay, that's the field value. So far so good.
Clicking a button that does a SKIP and a Form.Refresh() displays
"Assigning .F.", the optiongroup correctly updates to show the
second optionbutton selected, but then "Assigning .T." is shown
and the optiongroup switches back to the first button being
selected. Not good. As a result, as you skip through the
table, theField gets set to .T. as the record pointer hits each
record.
Any idea where this second assignment to .T. is coming from?
This seems very close to working and is a nice simple solution,
but this unexpected assignment is messing it up! Turning on
Event Tracking seems to indicate that the .T. assignment might
be happening when the form's Paint() method is envoked during the
form refresh.
Yes, I know that a checkbox can easily be used in this case,
but the interface calls for an optiongroup. I could change
the underlying table to a text field with "Y" and "N" values,
but leaving the field logical would be prefered for ease of
data processing.
-- TRW
_______________________________________
t i m . w i t o r t
_______________________________________