Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create an array. Help me!
Message
De
19/04/2000 10:49:33
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00361252
Message ID:
00361271
Vues:
14
>Hello all,
> I have been working with VFP not long ago so I don't know much about it and especially with array. Please help me if any of you know the answer!
> I am working on a form that has a grid, a combo box, and a button. The first column(of the grid) is Serial No. of on_hand items in the Inventory. The purpose of this form is to move items to co_locations(in other states) of the company.
> When I run the form, the grid will display all onhand items(with item name, received date to the inventory...) and I would like to create an array for all serial no.(the grid's first column) and store it under the combo box. If so, then I just click on the combo box to choose the item which has that particular serial no and go from there. But I don't know how to create an array like that.
> Any body please help me out!
> Thanks in advance.
> Thanya.


Thanya,
Really it doesn't need an array. But assuming still you want to get them into an array you could do this :

select distinct SerialNo from myTable into array aMyarray

Doing it this way you would have scope problems. For that reason first create a custom form property - say aMyItems[1]. Then do the same SQL as :

dimension thisform.aMyItems[1]
thisform.aMyItems[1] = ""
select distinct SerialNo from myTable into array thisform.aMyItems

There are many other ways to create that array. Now limitation :
If your SerialNo count goes beyond 65000 you'd hit array size limit (how could a combo would hold that info is another problem).

There are better ways. One is to set rowsourcetype to SQL and write SQL directly into Rowsource (my preference). Another one is to set Rowsourcetype to fields and rowsource to tablename.SerialNo. Yet another one is to loop through items and use AddItem, AddListItem. If you use option to set RowSourceType to fields, keep in mind that moving in combo moves record pointer (which is not desirable in cases). With SQL approach you could do like this :
*Combo.init
with this
 .RowsourceTYpe = 3 && SQL
 .RowSource = "select distinct SerialNo from myTable into cursor crsItems" endwith

*Combo.InteractiveChange or lostfocus
=seek(this.Value,"myTable","myTag")
thisform.MyGrid.Refresh()
OTOH, seeking in grid doesn't really need another control like combobox. See Ingrid class in files\classes section.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform