Rich,
The problem is so common (VFP bug) that I'm surprised you haven't run into this before.
See
Forms with Grids and printing reports FAQ #15515
>I'm running into this problem when I call a report and when I try to change pages. The code is
>SELECT stuff INTO CURSOR crsPrint READWRITE
>do some stuff with crsPrint to tweak the data
>REPORT FORM myReport PREVIEW
>
>At first when I try to run the report it would show up with the variable not found error message.
>
>So I put a breakpoint in and found that this wasn't the active workarea. Ok.......... I put SELECT crsPrint immediately before the call to REPORT FORM and tried again. SAME PROBLEM. The cursor was still not selected. Has anybody seen this before?????
>
>Next try was to wrap all this in a TRY-CATCH block
>SELECT stuff INTO CURSOR crsPrint READWRITE
>do some stuff with crsPrint to tweak the data
>TRY
> REPORT FORM myReport PREVIEW
>CATCH
> SELECT crsPrint
> REPORT FORM myReport PREVIEW
>ENDTRY
>
>The wierd thing is that it was now always pointing to the correct cursor the first time. But the problems are not over. There is a different manifistation of the same problem. The first page displays properly but the "Variable Not Found" error is now there when I try to go to the next/last page.
>
>The missing variable is actually a field in the cursor. The Report Form has many Data Groupings based upon various values for this field. There are groups for Variable = 1 thru Variable = 8 although the actual data cursor has MAX(variable) = 3
>
>Any information, suggestions, etc. appreciated...............Rich
If it's not broken, fix it until it is.
My Blog