I use SQL Select command into cusor A and set grid.recordsource="A".
However, since SQL select command gets nothing so there is no data in A. I
would like to add MESSAGEBOX() to be shown before it goes to empty grid
(there is no data in cursor A) but I have tried empty(),isnull() and
isblank() and received "variable A not found. Is there a way I can check if
cursor is empty or not? I am using select count(*) into array B and
?empty(B) for the evaluation as alternative.
Thanks for your time.
Char
A couple of options:
- Quick and dirty: Immediately after the SQL Select, check the
value of _TALLY:
SELECT [yada yada] INTO CURSOR MyCursor
lEmpty = _TALLY = 0
_TALLY is an internal counter used for various purposes by Fox,
including the number of records in a SQL Select. But it has to be
tested immediately, because other commands may change it!
- More general solution, IF there are no deleted records:
lEmpty = RECCOUNT(MyCursor) = 0
Note that RECCOUNT() will count deleted records, whether SET DELETED
is ON or OFF.
Also, I hope you aren't actually using 'A' and 'B' as cursor names,
as they refer to work areas 1 and 2 by default. That is, if you:
CLOSE DATA ALL
USE Table1 IN 0 && Table1 is opened in work area 1
USE Table2 IN 0 && Table2 is opened in work area 2
SELECT Table2 && work are 2 is selected
* The following will all return the value of Table1.Field1:
? Table1.Field1
? A.Field1
SELECT 1
? Field1
[Specifying alpha or numerical work areas is no longer good coding
practice, but sill works for the sake of backward compatibility.]
- Rush