Hi Gene.
>> I have a form with some combo boxes and the RowSource is fields from a
table. This is a default list of values for the user to pick. I want the user to be able to type something that is not on the list. The problem is that it will not save it to the Control Source in my table. I have put in the valid method --- "replace table.field with this.displayvalue" this will save it to the table but the combo box goes blank. <<
In addition to what Jim said, you can create a special combo class that lets you type a value in the textbox without having to add it to the list. Basically, what you do is unbind the control behind the scenes and manually update the controlsource in custom methods. This should get you started:
This code in the init:
IF DODEFAULT()
WITH This
.cControlSource = .ControlSource
.ControlSource = ''
ENDWITH
ENDIF
This in the refresh:
This.RefreshDisplayValue()
DODEFAULT()
This in the valid:
This.UpdateControlSource()
Here is RefreshDisplayValue:
LOCAL lcControlSource
WITH This
IF ! EMPTY( .cControlSource )
lcControlSource = .cControlSource
.DisplayValue = &lcControlSource
ENDIF
ENDWITH
And this is UpdateControlSource:
LOCAL lcAlias, lcControlSource
WITH This
IF ! EMPTY( .cControlSource )
lcAlias = JUSTSTEM( .cControlSource )
IF UPPER( ALLTRIM( lcAlias ) ) = 'THISFORM'
lcControlSource = .cControlSource
STORE .DisplayValue TO &lcControlSource
ELSE
REPLACE ( .cControlSource ) WITH .DisplayValue IN ( lcAlias )
ENDIF
ENDIF
ENDWITH
Marcia