Board index » delphi » Showing record x of y when dataset is filtered/showing SQL results

Showing record x of y when dataset is filtered/showing SQL results

In a status bar on a form, I have a label which displays record x of
y. This works fine, and changes as you move through the forms DBGrid,
but when I display search results using TQuery.SQL, the y variable
shows the correct number of results found, but the x still shows the
position of the record in the whole dataset, and not the subset I am
showing. SO it goes 3 of 2,  7 of 2 etc. How do I give each record a
number relative to it's position in the results of the query?

I thought this might be a common problem, but I haven't found anything
about it anywhere...

Thanks

Finn Austin

 

Re:Showing record x of y when dataset is filtered/showing SQL results


There is no (to the best of my knowledge) property or method that will
give you this information. If resulting data set is not huge, you will
have to maintain an internal cross ref linked list or dynamic array
which you will fill by first stepping thru the result set. So if the
recNo property gives you a number, say, 19, your cross ref. list will
tell you to display 6 (or what ever) instead.

Hope it helps.

Regards,
Nasir

Other Threads