Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use Optiongroup with logical data?
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01187180
Message ID:
01187189
Views:
15
>A client wants an Optiongroup with Yes and No as choices for a logical field (bit datatype in SQL.) It seemed a reasonable request but now I'm not so sure that it's even possible. If so, what's the trick?
>
>The Optiongroup itself doesn't accept logical data but the Optionbuttons do. If you can't specify the field as the controlsource for the Optiongroup, how are the buttons supposed refresh properly and update the field. This must be incredibly simple but it eludes me at the moment.

There where you refresh the values of the controls, or move to Next, Previous records:
thisform.OptionGroup1.Value = IIF(MyField, 1, 2)
WITH EVALUATE([thisform.OptionGroup1.Option]+TRANSFORM(thisform.OptionGroup1.Value))
     .SetFocus() &&& Move a little square around the buttons to appropriate one.
ENDWITH
In InterActiveChange Event of th OptionGroup:
REPLACE MyField WITH (this.Value == 1) IN MyTable
Here one example (no error handling in it)
* Mode MS-original

PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


    **************************************************
*-- Form:            form1 (d:\all_zapl_4_9_0\test.scx)
*-- ParentClass:     form
*-- BaseClass:       form
*-- Time Stamp:      01/19/07 11:01:11 PM
*
DEFINE CLASS form1 AS form


    Top = 0
    Left = 0
    Height = 200
    Width = 200
    DoCreate = .T.
    Caption = "Form1"
    ForeColor = RGB(255,255,255)
    Name = "Form1"


    ADD OBJECT optiongroup1 AS optiongroup WITH ;
        ButtonCount = 2, ;
        Value = 1, ;
        Height = 46, ;
        Left = 0, ;
        Top = 59, ;
        Width = 71, ;
        Name = "Optiongroup1", ;
        Option1.Caption = "Yes", ;
        Option1.Value = 1, ;
        Option1.Height = 17, ;
        Option1.Left = 5, ;
        Option1.Top = 5, ;
        Option1.Width = 61, ;
        Option1.Name = "Option1", ;
        Option2.Caption = "No", ;
        Option2.Height = 17, ;
        Option2.Left = 5, ;
        Option2.Top = 24, ;
        Option2.Width = 61, ;
        Option2.Name = "Option2"


    ADD OBJECT command1 AS commandbutton WITH ;
        Top = 58, ;
        Left = 100, ;
        Height = 27, ;
        Width = 84, ;
        Caption = "Next", ;
        Name = "Command1"


    ADD OBJECT command2 AS commandbutton WITH ;
        Top = 86, ;
        Left = 100, ;
        Height = 27, ;
        Width = 84, ;
        Caption = "Prev", ;
        Name = "Command2"


    PROCEDURE Init
        CREATE CURSOR crsTest (Fld1 L)
        INSERT INTO crsTest VALUES(.f.)
        INSERT INTO crsTest VALUES(.t.)
        GO TOP
        ThisForm.RefreshControls()
    ENDPROC


    PROCEDURE refreshcontrols
        thisform.Optiongroup1.Value = IIF(crsTest.Fld1,1,2)
        WITH EVALUATE([thisform.OptionGroup1.Option]+TRANSFORM(thisform.OptionGroup1.Value))
             .SetFocus() 
        ENDWITH
    ENDPROC


    PROCEDURE optiongroup1.InteractiveChange
        REPLACE Fld1 WITH (this.Value == 1) IN crsTest
    ENDPROC


    PROCEDURE command1.Click
        SKIP
        thisform.Refreshcontrols()
    ENDPROC


    PROCEDURE command2.Click
        SKIP -1
        thisform.Refreshcontrols()
    ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform