Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

count in grid 1

Status
Not open for further replies.

foxup

Programmer
Dec 14, 2010
328
CA
Hi,

I can't seem to wrap my head around this simple task. So, I have a form with a grid and simple label on the grid. In the label-click I have:
USE ETHORDERS
SET ORDER TO EORDERID DESC
SET FILTER TO SUBSTR(INTERN_QID,1,1)="B"
GO TOP
THISFORM.grid1.REFRESH()

easy enuf.

Now at the bottom of the form I wanna display the simple count. Example:

XX Records meet criteria

Is there a very simple way of doing so?

My brain is in neutral today and I can't seem to figure this simple task out.

Any help please.

Thanks,
J
 
Well, you can't use RECCOUNT(), because that gives you the total number of records in the file (as opposed to the filter).

And you can't do SELECT COUNT(*) FROM Ethorders (for much the same reason).

But what you can do this this:

Code:
DIMENSION ARRAY laResults(1)
SELECT COUNT(*) FROM Ethorders WHERE SUBSTR(INTERN_QID,1,1)="B" INTO ARRAY laResults
THISFORM.Label1.Caption = TRANSFORM(laResults(1)) + " meet the criterion"

Obviously, if you used a different filter, you would have to change the WHERE clause.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
OK, I just thought there might have been a quicker / simpler way. Some sort of built in function. I erred. Thanks Mike.

Ciao for now,
J

 
Another solution is [COUNT To lnCount], it will respect the filter while counting, but it will also put the record pointer to EOF.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top