Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Optiongroup.Controlsource = a logical field
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00057117
Message ID:
00057128
Views:
32
>>Not supposed to do that, since the value is numeric. But I want the effect of that. Consider a table of people with a logical sex field, where .T. is considered female and .F. male. To FoxPro, such a field means "female, true or false." But imagine a form with a check box and a caption "Female?" Looks pretty dumb. The appropriate control is an option group with one button labeled "male" and the other "female."
>>
>>I left the optiongroup.ControlSource blank, then set Option2.ControlSource = mytable.female and Option1.ControlSource = !mytable.female. That almost worked. When I navigated the table with my form, the option buttons updated correctly. But when I tried to edit a record, the buttons wouldn't switch. When I edited a female record and clicked the male option button, the female button turned off but the male button didn't turn on. Then it didn't save the change.
>>
>>I know I can use code in the OptionGroup.Click and the Form.Refresh to update the controlsource, but I like controlsources. Can it be done?
>
>If you like controlsource so much than cannot live without them, then you could do following:
>1. Make invisible checkbox with controlsource "mytable.female"
>2. Clean controlsource for the optiongroup (sorry about this)
>3. Add code to OptionGroup.InteractiveChange to reset Checkbox.value
>4. Add code to Checkbox.ProgrammaticChange to reset OptionGroup.Value
>Surely, it's overhead, but you like controlsources.

I don't like them THAT much. I like controlsources because I like not having to scatter code in .Valid or .Refresh methods to get fields updated. If the controlsources for the option group and its buttons are good for nothing, so be it.

I seem to remember that you don't use the controlsource property at all. Is that true? Why not? What do you do instead?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform