Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combo Boxes
Message
From
19/06/2002 14:40:06
 
 
To
19/06/2002 11:49:51
Jim Rieck
Quicken Loans/Rock Financial/Title Sourc
Livonia, Michigan, United States
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Miscellaneous
Thread ID:
00670161
Message ID:
00670246
Views:
19
Hello Jim.

Hopefully this is a simple one. I have a combo box that the user will type something into. I am saving the information in the valid event of the combo box with a replace command. I am replacing the field with the value property of the combo box, but the field is empty. What am I doing wrong?

I think that you are misunderstanding the control and how to use it. There are 2 issues here that you need to understand. Typically, combos are used to display the descriptive text associated with some key value that is taken from a lookup table of some sort. The data from the lookup table is used to populate the control's internal list. You can, for example, set the combo's properties as follows:

RowSourceType = 6-fields
RowSource = 'MyLookupTable.DecriptiveField, KeyField'
BoundColumn = 2
BoundTo = .T.

Now, suppose you have another table that needs to store, as a foreign key, the value of the key field from the lookup table. In order to make that happen, all you need to do is set the combo's ControlSource to that DataTable.Field. When the user selects something from the combo's internal list, it will automatically update its controlSource.

If, OTOH, you are talking about adding items on the fly to a combo with style=0-DropDown combo, this is a separate issue. In this case, you need to take some action to add the new item to the lookup table and upddate the combo's internal list by issuing a combo.requery() like so in the combo's valid:
WITH This
  IF NOT EMPTY( .DisplayValue ) AND .ListIndex = 0
    INSERT INTO MyLookupTable ( DescriptiveField ) VALUES ( .DisplayValue )
    *** This assumes that there is a Default Value being generated for the PK field in the lookup table
    lnKey = MyLookupTable.KeyField
    .Requery()
    .Value = lnKey
  ENDIF
ENDWITH
Note that the above code is untested and off the top of my head.

HTH
Previous
Reply
Map
View

Click here to load this message in the networking platform