Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combobox driving me crazy....
Message
From
04/04/2002 22:39:06
Ken Dibble
Southern Tier Independence Center
Binghamton, New York, United States
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00641186
Message ID:
00641233
Views:
12
>This shouldn't be so hard....
>
>What I'm trying to do is create a self-contained combobox class that will dropdown a Yes/No option, placing a corresponding .t. or .f. into a table.

Hi Steve,

Would this work? Put this on a form and set the value of YesNoSource to
[some table].[some field]:
DEFINE CLASS Yncombo AS Combobox
     RowSourceType = 1
     RowSource = "Yes,No"
     Style = 2
     FieldName = ""
     TableName = ""
     YesNoSource = ""

     PROCEDURE Init
          LOCAL dotspot, thetable, thefield

          dotspot = AT(".",THIS.YesNoSource)

          STORE LEFT(THIS.YesNoSource,(dotspot - 1)) TO THIS.TableName
          STORE SUBSTR(THIS.YesNoSource,(dotspot + 1)) TO THIS.FieldName

          STORE THIS.TableName TO thetable
          STORE THIS.FieldName TO thefield

          IF USED("&thetable")
               IF &thefield = .T.
                    THIS.Value = "Yes"
               ENDIF

               IF &thefield = .F.
                    THIS.Value = "No"
               ENDIF

               IF ISNULL(&thefield)
                    THIS.Value = ""
               ENDIF
          ELSE
               THIS.Value = ""
          ENDIF
     ENDPROC

     PROCEDURE Valid
          LOCAL thetable, thefield

          STORE THIS.TableName TO thetable
          STORE THIS.FieldName TO thefield

          IF NOT EMPTY(THIS.DisplayValue)
               IF NOT USED("&thetable")
                    MESSAGEBOX("The Yes/No Combobox data source is not open.")
                    THIS.DisplayValue = ""
                    RETURN
               ENDIF
          ENDIF

          IF THIS.DisplayValue = "Yes"
               REPLACE &thefield WITH .T.
          ENDIF

          IF THIS.DisplayValue = "No"
               REPLACE &thefield WITH .F.
          ENDIF

          IF EMPTY(THIS.DisplayValue)
               REPLACE &thefield WITH .F.
          ENDIF
     ENDPROC
ENDDEFINE
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform