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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alias Not Found 1

Status
Not open for further replies.

jerry1117

Programmer
Sep 29, 2003
20
US
I am using VFP 7.0 and running a VFP SELECT statement to build a cursor (rpt) for a report. When I SELECT the cursor (SELECT rpt), I occasionally get an alias not found error. Sometimes I don't get the error.

The SELECT statement to build the cursor runs correctly (i.e. the program does not fail with an error on the SELECT statement), and I have not closed the cursor. Does anyone have any ideas why I am getting the alias not found error?

Thanks,
Jerry
 
If a grid has focus when you tring to print, this could happen. Just make sure that some other control has focus before you print. Something like:
Code:
thisform.MyControlTahtIsNotGrid.SetFocus()
REPORT FORM ....

Borislav Borissov
 
Thanks for the input, but I am doing all this in a single method. Here is the code.
*********************************************************
WAIT WINDOW "Building report data; please wait..." NOWAIT
SELECT tempamerge_adults.*,;
tempamerge_adults.p01fname as adult_name,;
temp_ajunction.p09fname as name;
from tempamerge_adults LEFT OUTER JOIN temp_ajunction on;
tempamerge_adults.p10fkp09pktrng = temp_ajunction.p09pk OR;
tempamerge_adults.p10pafkp09pk = temp_ajunction.p09pk;
where NOT EMPTY(ALLTRIM(tempamerge_adults.p10action)) ;
INTO CURSOR rpt
pnRecs = RECCOUNT()
WAIT CLEAR
IF RECCOUNT() <> 0
DO WHILE .T.
PUSH KEY CLEAR
*BROWSE
Report Form Fullpath("reports/mergeresults.frx") To Printer Prompt Preview
POP KEY
lnAnswer = MESSAGEBOX("Do you need to reprint the merge results report?", ;
MB_ICONQUESTION + MB_YESNO + MB_DEFBUTTON1, ;
ADCAPP_LOC)
IF lnAnswer = IDNO
EXIT
ENDIF
ENDDO
ENDIF
SELECT rpt && this is the select that fails
&& with alias not found
USE
*********************************************************

Jerry
 
No metter in what method you do this, just make sure that the GRID doesn't have a focus.

Borislav Borissov
 
I know it sounds a daft situation but Boris is right. I had the same problem about six months back and he solved it for me with the same advice. If you've got a grid on the form then make very sure that it doesn't have focus when you run a report.

Geoff Franklin
 
Thanks again for the input, but there is no grid object on the form. Just some command buttons, and a checkbox. Jerry
 
Code:
SELECT (SELECT('rpt'))
USE
will eliminate the error

Mike Krausnick
Dublin, California
 
Mike, I put the fix in the program. I will cut it over tonight, and see how it goes. Since the problem does not occur every time, I will wait a few days before reporting the results back. Thanks, Jerry
 
Not necesary, If the alias is not used
USE IN 0 will be executed and no table will be affected

Borislav Borissov
 
Borislav, Jerry doesn't want to USE the table, he wants to CLOSE it. That's why I suggested the code
Code:
SELECT (SELECT('rpt'))
USE
which will select he 'rpt' area if it exists or 0 if it does not. Then USE will close the table.

Mike Krausnick
Dublin, California
 
Borislav, and Mike,

Thanks for all your input. The tip you have given me will, indeed, get rid of the error I was getting when I selected 'rpt', and it was not available.

What really bothers me, though, is why is 'rpt' not available? If you don't mind, look at the code I submitted above. I am not using grids, like Borislav suggested, so why is 'rpt' not available?

Thanks, Jerry
 
Jerry, If I was on your place I surelay will debug that situation. What cause this behaviour? Can I be sure that this could not happen just before report printing? So Make a break ponit in debuget with:
Break if Expression is true-> in the expression put:
SELECT("Rpt") == 0
I am not sure if VFP 7 has ASSERTS but try:

Code:
*********************************************************
SET ASSERTS ON
WAIT WINDOW "Building report data; please wait..." NOWAIT
SELECT tempamerge_adults.*,;
tempamerge_adults.p01fname as adult_name,;
temp_ajunction.p09fname as name;
from tempamerge_adults LEFT OUTER JOIN temp_ajunction on;
tempamerge_adults.p10fkp09pktrng = temp_ajunction.p09pk OR;
tempamerge_adults.p10pafkp09pk = temp_ajunction.p09pk;
where NOT EMPTY(ALLTRIM(tempamerge_adults.p10action)) ;
INTO CURSOR rpt

ASSERT .f. && Here select debug
pnRecs = RECCOUNT()
WAIT CLEAR
IF RECCOUNT() <> 0
    DO WHILE .T.
        PUSH KEY CLEAR
        *BROWSE
        Report Form Fullpath("reports/mergeresults.frx") To Printer Prompt Preview
        POP KEY
        lnAnswer = MESSAGEBOX("Do you need to reprint the merge results report?", ;
                      MB_ICONQUESTION + MB_YESNO + MB_DEFBUTTON1, ;
                      ADCAPP_LOC)
        IF lnAnswer = IDNO
            EXIT
        ENDIF
    ENDDO
ENDIF
USE IN SELECT ("Rpt")
and step over until Rpt was closed.


Mike,

USE IN Rpr && Close the Table/Cursor that is opened as Rpt

USE IN 11 && Close Table/Cursor that is opened in alias 11


USE IN SELECT("Rpt") && Close Table/Cursor by numeric alias where cursor Rpt is Opened. If Rpt in already closed noithing happens.

Boris

Borislav Borissov
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top