Microsoft KB Archive/126969

= PRB: Running Genxtab with an Empty Table Causes Error =

Article ID: 126969

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.5b
 * Microsoft FoxPro 2.6 Standard Edition
 * Microsoft FoxPro 2.6a Standard Edition
 * Microsoft FoxPro 2.5b for MS-DOS
 * Microsoft FoxPro 2.5a
 * Microsoft FoxPro 2.5b for MS-DOS
 * Microsoft FoxPro 2.6 for MS-DOS
 * Microsoft FoxPro 2.6a Standard Edition

-



This article was previously published under Q126969



SYMPTOMS
When GENXTAB.PRG is run from an application, and the current table or cursor does not contain any records, GENXTAB.PRG issues one of the following error messages:
 * Cannot prepare crosstab on empty database. -or-


 * Variable '_WIN' not found.

In either case, the error message will appear, and your program will exit.



CAUSE
Cross tabulation requires that a table or cursor (usually the result of a query) with only three fields be open in the selected work area.



RESOLUTION
Please see the workaround listed in the "More Information" section of this article.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
  Copy one of the following sections of code, depending on your version of FoxPro, to a PRG file. The SELECT, DO (_GENXTAB), and BROWSE NOMODIFY lines were created using the RQBE and copied to a PRG:

Code for FoxPro 2.x
IF !USED("customer") USE customer ENDIF

STORE "C:\\GENXTAB.PRG" TO _GENXTAB

SELECT Customer.cno, Customer.state, Customer.ytdpurch; FROM Customer; GROUP BY Customer.cno, Customer.state; ORDER BY Customer.cno, Customer.state; WHERE alltrim(upper(state))="JP" INTO CURSOR SYS(2015) DO (_GENXTAB) WITH 'Query' BROWSE NOMODIFY WAIT WINDOW "HELLO WORLD" The WHERE clause in the SELECT statement returns an empty cursor. Therefore, the BROWSE and WAIT WINDOW commands after the DO (_GENXTAB) WITH 'Query' will never get executed.

Code for Visual FoxPro
IF !USED("customer") USE c:\vfp\samples\data\customer ENDIF

SELECT Customer.cust_id, Customer.company, Customer.maxordamt; FROM customer; WHERE Customer.state = "WJ"; GROUP BY Customer.cust_id, Customer.company; ORDER BY Customer.cust_id, Customer.company; INTO CURSOR SYS(2015) DO (_GENXTAB) WITH 'Query1' BROWSE NOMODIFY WAIT WINDOW "HELLO WORLD"  Create a new project, and add the program to the project. Build an .EXE or .APP from the project. Run the .EXE or .APP and notice that the BROWSE and WAIT WINDOW commands will not be executed.</ol>

<div class="workaround_section">

WORKAROUND
<ol>  Replace the program listed above with the following: IF !USED("customer") USE customer ENDIF

STORE "C:\<FoxPro Directory>\GENXTAB.PRG" TO _GENXTAB

SELECT Customer.cno, Customer.state, Customer.ytdpurch; FROM Customer; GROUP BY Customer.cno, Customer.state; ORDER BY Customer.cno, Customer.state; WHERE alltrim(upper(state))="JP" INTO CURSOR SYS(2015)

IF _TALLY !=0 &&if results are equal to 0 GENXTAB.PRG WILL NOT EXECUTE DO (_GENXTAB) WITH 'Query' BROWSE NOMODIFY ENDIF

WAIT WINDOW "HELLO WORLD" </li> Create a new project, and add the program to the project.</li> Build an .EXE or .APP from the project.</li> Run the .EXE or .APP and notice that the WAIT WINDOW command is now executed.</li></ol>

Additional query words: VFoxWin FoxWin FoxDos 2.50c

Keywords: KB126969

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.