Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
User Filled Combo
Message
De
23/11/1999 03:28:38
 
 
À
22/11/1999 14:54:07
Jimmy Ditta
Twin City Electronics
Monroe, Louisiane, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00293857
Message ID:
00294241
Vues:
33
Hi Jimmy.

>> the code in the valid event of the combo: <<

OK. I just finished some testing, and this works for me. It should work for you since the BoundColumn of your ComboBox is Column 1:
WITH This
  IF .ListIndex = 0 AND !EMPTY( .DisplayValue )
    IF !USED( 'company_tbl' )
      use company_tbl in 0
    ENDIF
    INSERT INTO company_tbl VALUES ( .DisplayValue )
    .Requery()
    .Value = .DisplayValue
  ENDIF
ENDWITH
Generally speaking, I use my combo boxes to display the desriptive text from a lookup table while setting its BoundColumn to 2 (this column contains the Primary Key of the entry in the lookup table). Then I just store the primary key of the lookup table entry as a foreign key in my data file. Since I use integer surrogate primary keys, I must also set BoundTo to true (This tells VFP to take the combo's value from its List rather than its Index when its value is numeric). I just set my columncount to 2 and set the column width of the 2nd column to 0 so the end-user never sees the surrogate key (which means nothing to him < s > )

If you were doing things like I just described, the code I gave you would not work. The only reason it will work for you is because your BoundColumn is column 1. Instead, you would have to set the value of the combo to the value of the surrogate key that you inserted into the company_tbl. The code would (in this case) go something like this:
LOCAL lnKeyValue

WITH This
  IF .ListIndex = 0 AND !EMPTY( .DisplayValue )
    IF !USED( 'company_tbl' )
      use company_tbl in 0
    ENDIF
    lnKeyValue = NEWID( 'company_tbl' )
    INSERT INTO company_tbl VALUES ( lnKeyValue, .DisplayValue )
    .Requery()
    .Value = lnKeyValue
  ENDIF
ENDWITH
If you need to see how such a NEWID funstion would work, check out Tastrade, the sample application that ships with VFP. This is a stored procedure in the dbc.

HTH

Marcia
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform