Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Number of records in a grid
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00575563
Message ID:
00575826
Vues:
26
This message has been marked as the solution to the initial question of the thread.
>>How are you looking back? If you select the work area and use commands like SCAN/ENDSCAN, COUNT, SUM, etc. then you should get the buffered data.
>>
>>If you use SQL statements then you won't because it uses the underlying table opened in a new workarea and this wouldn't have the new changes. This is also true if you open the alias again under a new alias manually.
>
>I was using a SQL because the orginial table has hundreds of thousands of records and typically there is only 3 or 4 records related to the parent table. I find that using anytype of SCAN/ENDSCAN is very time consuming. I was just hoping there was some method or way to identify the small number of records in my grid (ususally 6 or less) I was hoping to find a way to go top, go bottom in grid and somehow determine the numer of rows, but unable to determine the number of rows in grid!! I was trying to get count of records with RECNO() less then 0 but this is very timeconsuming as well.
>
>Thanks for your suggestions, but it looks like the tableupdate option will be more favorable being controlled from the class than the form.

While the SQL select is a good way to get a small number of rows, it is usually not the best way in cases like this. Try the following:
select grid.recordsource
set order to ForeignKeyIndex
if seek(myparentkey) then
   count to lncount while foreignkey = myparentkey
else
   lncount = 0
endif
The SEEK() function and COUNT command will operate on the buffered data. they will also take into account the DELETED flag if you happen to delete a record.

The WHILE clause of the COUNT command will make VFP operate using the index. All the records that are associated with the current parent will be counted. If you save the current record pointer, you can then position the record pointer back at the end of the process.

Using a combination of SEEK and COUNT WHILE can be lightning fast. In many cases, it is faster than a corresponding SELECT COUNT(*) because VFP doesn't have to determine anything. Indexes to use for optimization are predetermined for it and it just has to do the grunt work of processing the data.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform