Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combo Boxes
Message
De
19/06/2002 14:40:06
 
 
À
19/06/2002 11:49:51
Jim Rieck
Quicken Loans/Rock Financial/Title Sourc
Livonia, Michigan, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Titre:
Divers
Thread ID:
00670161
Message ID:
00670246
Vues:
18
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform