Hello all,
Can you please help me to understand whats going on here and what can be done about it ?
The following code creates some cursors and a form with come combo boxes. The controlsource for the combos are a data object of the form that is scatter name 'ed when you move to a new record. Everything works fine except when you choose a new value from the fruits combo the change is not reflected in the displayvalue but the correct value is stored in the data object ??
Create Cursor x_ExampleFruits( iID i , cText c(20) )
Insert Into x_ExampleFruits( iID , cText ) Values( 1 , "Apples" )
Insert Into x_ExampleFruits( iID , cText ) Values( 2 , "Bananas" )
Insert Into x_ExampleFruits( iID , cText ) Values( 3 , "Grapes" )
Insert Into x_ExampleFruits( iID , cText ) Values( 4 , "Oranges" )
Insert Into x_ExampleFruits( iID , cText ) Values( 5 , "Peaches" )
Create Cursor x_ExampleSizes( cSize c(20) )
Insert Into x_ExampleSizes( cSize ) Values( "Small" )
Insert Into x_ExampleSizes( cSize ) Values( "Medium" )
Insert Into x_ExampleSizes( cSize ) Values( "Large" )
Create Cursor x_Data( iID i , yCost Y , iFruit_id i , cSize c(15) )
Insert Into x_Data( iID , yCost , iFruit_id , cSize ) Values( 1 , 1.25 , 2 , "Large" )
Insert Into x_Data( iID , yCost , iFruit_id , cSize ) Values( 2 , 2.52 , 4 , "Medium" )
Insert Into x_Data( iID , yCost , iFruit_id , cSize ) Values( 3 , 3.00 , 3 , "Small" )
Index On iID Tag iID
oForm = Crea("myForm")
oForm.Show(1)
Define Class myForm As Form
DoCreate = .T.
BindControls = .F.
Name = "Baseform1"
odataobj = Null
Width = 500
Add Object lbodata As ListBox With ;
FontName = "Tahoma", ;
FontSize = 8, ;
ColumnCount = 2, ;
ColumnWidths = "85,100", ;
RowSourceType = 2, ;
Height = 193, ;
Left = 8, ;
Top = 24, ;
Width = 192, ;
Name = "lboData"
Add Object cboexamplecombo As ComboBox With ;
FontName = "Tahoma", ;
FontSize = 8, ;
BoundColumn = 2, ;
RowSourceType = 2, ;
ControlSource = "thisForm.oDataObj.iFruit_id", ;
Enabled = .F., ;
Height = 25, ;
Left = 208, ;
Style = 2, ;
Top = 48, ;
Width = 157, ;
BoundTo = .T., ;
Name = "cboExampleCombo" ,;
disabledBackColor = Rgb(115,115,115) ,;
disabledForeColor = 0
Add Object cbononnumericcontrolsource As ComboBox With ;
FontName = "Tahoma", ;
FontSize = 8, ;
RowSourceType = 2, ;
ControlSource = "thisForm.oDataObj.cSize", ;
Enabled = .F., ;
Height = 25, ;
Left = 208, ;
Style = 2, ;
Top = 108, ;
Width = 157, ;
Name = "cboNonNumericControlSource" ,;
disabledBackColor = Rgb(115,115,115) ,;
disabledForeColor = 0
Add Object label1 As Label With ;
AutoSize = .T., ;
FontName = "Tahoma", ;
FontSize = 8, ;
BackStyle = 0, ;
Caption = "Fruit", ;
Height = 15, ;
Left = 213, ;
Top = 34, ;
Width = 24, ;
Name = "Label1"
Add Object label2 As Label With ;
AutoSize = .T., ;
FontName = "Tahoma", ;
FontSize = 8, ;
BackStyle = 0, ;
Caption = "Size", ;
Height = 15, ;
Left = 213, ;
Top = 94, ;
Width = 21, ;
Name = "Label2"
Add Object cmdsavechanges As CommandButton With ;
Top = 46, ;
Left = 375, ;
Height = 27, ;
Width = 84, ;
FontName = "Tahoma", ;
FontSize = 8, ;
Caption = "Edit", ;
Name = "cmdSaveChanges"
Add Object txtFruitIDValue As TextBox With ;
Top = 86, ;
Left = 375, ;
Height = 27, ;
Width = 54, ;
FontName = "Tahoma", ;
FontSize = 8, ;
ControlSource = "thisForm.oDataObj.iFruit_id", ;
Name = " txtFruitIDValue"
Procedure Init
Parameters iSeekID
With Thisform
.lbodata.Requery()
.lbodata.Click()
.cboexamplecombo.Requery()
.cbononnumericcontrolsource.Requery()
.BindControls = .T.
Endw
Endproc
Procedure lbodata.Requery
With This
.RowSource = ''
Select cSize , cText , x_Data.iID ;
FROM x_Data ;
INNER Join x_ExampleFruits ;
ON x_ExampleFruits.iID = x_Data.iFruit_id ;
ORDER By 3 ;
INTO Cursor rs_LboData
.RowSource = 'rs_LboData'
Endwith
Endproc
Procedure lbodata.Click
With Thisform
If Seek( rs_LboData.iID , "x_Data" , "iID" )
Select x_Data
Scatter Name .odataobj Memo
.Refresh()
Endif
Endw
Endproc
Procedure cboexamplecombo.Requery
With This
.RowSource = ''
Select cText , iID ;
from x_ExampleFruits ;
order By 1 ;
into Cursor rs_CboExample
.RowSource = 'rs_CboExample'
Endw
Endproc
Procedure cboexamplecombo.Valid()
Thisform.Refresh()
Endproc
Procedure cbononnumericcontrolsource.Requery
With This
.RowSource = ''
Select cSize ;
from x_ExampleSizes ;
order By 1 ;
into Cursor rs_CboNonNumeric
.RowSource = 'rs_CboNonNumeric'
Endw
Endproc
Procedure cmdsavechanges.Click
With Thisform
.lbodata.Enabled = Not .lbodata.Enabled
.cboexamplecombo.Enabled = Not .cboexamplecombo.Enabled
.cbononnumericcontrolsource.Enabled = Not .cbononnumericcontrolsource.Enabled
Endwith
If This.Caption = "Save Changes"
Select x_Data
Gather Name Thisform.odataobj Memo
Thisform.lbodata.Requery()
This.Caption = "Edit"
Else
This.Caption = "Save Changes"
Endif
Endproc
Enddefine
Greg Foote
Software At Work, Inc.