Property Initial Value
-------- -------------
r_cControlSource {None}
r_cNumVal {None}
r_lVariable .F.
Method: m_ChangeValue
3. Set the ControlSource property to: This.r_cNumVal
4. Add the following code to methods:
* Refresh Method:
This.r_cNumVal = Alltrim(Str(Eval(This.r_cControlSource)))
* Valid Method
IF Eval(This.r_cControlSource) # Val(This.r_cNumVal)
=This.m_ChangeValue(Val(This.r_cNumVal))
ENDIF
* m_changevalue Change the value of a field or variable
* named in .r_cControlSource
* ANW 12/97
Parameter p_xNewValue
Local l_c
If This.r_lVariable
l_c = This.r_cControlSource
&l_c = p_xNewValue && It's a variable
ELSE
l_c = This.r_cControlSource
IF AT('.',l_c) > 0
l_c = "REPLACE " + Right(l_c,len(l_c)-at('.',l_c))+ ;
" WITH p_xNewValue" + ' IN ' + left(l_c,at('.',l_c)-1)
&l_c
ELSE
REPLACE (This.r_cControlSource) WITH p_xNewValue
ENDIF
ENDIF
5. Implementation: Replace all your combo boxes which have these key values with a combobox of class cboNumber. Set your properties just like you usually would:
BoundColumn, RowSource, RowSourceType, ColumnWidths. But DO NOT change the ControlSource property. Instead, change r_cControlSource. Also, if
r_cControlSource is a variable, not a field value, set Combo.r_lValiable to .T.
The only problem you have to worry about now is that this solution doesn't work well in a grid. I have a grid solution but it is less elegant. Also, you could probably figure out a way to determine whether r_cControlSource is a field or a variable without an explicit reference like that. But I leave that to sharper minds.
Adam