Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Change value in combo
Message
 
À
14/04/2001 05:39:59
Ben Dekker
Dekker Soft & Hardware
Axel, Pays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00494464
Message ID:
00495558
Vues:
16
>My first object in the form is a combo
>in the valid event i have the next code now
>
>
replace user.name with this.displayvalue
>thisform.refresh
>
>as properties i use
>
>control source user.name
>rowsource user.name
>rowsource typ 6-fields
>style 0-dropdown combo
>
>when i open the the first name of the table is shown in the combo
>when i search an other name the from is working fine
>when i add a name I can fill in the value's and it's working
>fine. But when I change a name its change the record before the record
>pointer ( i change record 10 but it change record 9)
>
>Ben


Hi Ben,

It looks like you have a form with user info.
On that form you have a dropdown combo where you want to have the ability to choose a name, an then see the info of that person on the form.
I assume that you don't want to change the name of a user to the name of the other user?
And you want to make it possible to change the names?

Correct me, if i'm wrong but this is what i understand from the rest of the thread.

The simplest way to archieve this is to have a combobox to select the user, and a textbox to eventually change the name.

Another way is to use a view with all the names in the rowsource.
Set the rowsourcetype to View, and in the Rowsource place
Select name from users into cursor cNames
Then you don't have the problem that the list from which you select a value is the same as the table where the data is written to.
In the valid event you can place the following code:
 * Combobox.valid()
SELECT USERS
IF NOT EMPTY( This.DisplayValue ) && Only if the display value is not empty searching is needed
   If This.ListIndex = 0  && First look if the value already exists in the list
      && If not, then replace the name with the new value
      REPLACE Users.Name with This.DisplayValue
      && Then requery the view with the list of names in it. (This is the view from the rowsource)
      Requery('cNames')
      && The last thing needed is to requery the combo itself. By doing this the list with names in the combo will be updated.
      This.Requery()
   ELSE
      && If the value is in the list, we can simply look up the requested user.
      SEEK This.DisplayValue
   ENDIF
ENDIF
HTH,
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform