Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ListBox mover button update question
Message
De
22/11/2000 13:53:09
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00444603
Message ID:
00444697
Vues:
9
>>Not a bother :)
>>OK, let me ask you a couple of questions before I answer again, as I think I >have confused the issue.
>>1) Is the ItemID the unique identifier for the row? (primary key, e.g.)
>>2) If not, what is?
>
>I take all the collateral items for a given loan and load them into table otemp. There is NO unique key defined for otemp. But logically the combination of loannum, coll_seq is unique. loannum is the same for all the rows so that is not a problem. coll_seq is only used for display order. It is not reference anywhere except in the index for display purposes.
>
>After they move the rows around and click OK. I want to loop through the otemp table and get each row's otemp.coll_seq and find it in the listbox. Then replace the otemp.coll_seq with the new order in the listbox. If it is now row 3 then the otemp.coll_seq = 3.
>
>Thanks
>
>Brenda

How are you planning to write back the new sequence to this source table from oTemp? Or are you? Would the user have to reorder the sequences each time?

Is oTemp a cursor or actually a table? If a table, is it removed after you're done with it?

Is there a PK on the loan table - i.e., the source for oTemp?

If not, I strongly suggest adding a primary key to the the loan table - not a combination of loannum and coll_seq, but a surrogate key - i.e., a field whose only purpose is to uniquely identify that row in the table, regardless of how the data changes w/in the other fields of the row.
There are several ways of doing this.
See the Tastrade example in help for one of the more popular ways of doing this, by using a pk generation table.
Or you can use SYS(2015)

Once you have a pk for the loan table, load up the oTemp cursor including the pk field from the loan table. This example again assumes a numeric pk.
Then load up the listbox from oTemp with the description and pk, e.g.
select oTemp
with thisform.listbox
  .ColumnCount = 1
  .AddItem(otemp.coll_desc)
  .AddItem(Transform(otemp.pkloan), .NewItemID, 2)
endwith
The listbox is now loaded with 2 columns - 1 visible (coll_desc) and 1 not (pkloan)
3) the user changes the order and clicks OK, write back to oTemp from the listbox, e.g.
select otemp
with thisform.listbox
  for ji = 1 to .ListCount
    replace coll_seq with ji for pkloan = val(.List(ji,2)) in otemp
  endfor
endwith
4) when writing back to the loan table from oTemp, do pretty much the same thing
select otemp
scan
  update loan ;
    set coll_seq = otemp.coll_seq ;
    where pkloan = otemp.pkloan
endscan
Insanity: Doing the same thing over and over and expecting different results.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform