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

Cursor in Data Environment

SitesMasstec

Programmer
Joined
Sep 26, 2010
Messages
579
Location
Brasil
Hello colleagues!

A have a Form which has in its Data Environment the table TEMPREC2.DBF (it is a temporary table with selected records from another table).

Is it possible to have a Cursor in the Data Environment of the Form, instead of that table?

Cursor has a random name, so I could not define it in the Data Environment of the Form. Is there another way to do it?

Thank you.
 
you can create and populate your cursor in a new method defined in your form.
this new method can be called from Form.init method
 
The data environment can contain:
1. Tables
2. Views
3. Cursoradapters

So the direct answer is no. You can create a view that queries the data, you can create a cursoradapter that queries the data, but I doubt you'd want that, as it has much overhead and not just the query. Instead, just write a query INTO CURSOR in code, like in the Load event of a form or in the BeforeOpenTables event of the data environment.

I would recommend the Load event of the form, as code in there is easier to discover, later, to see code of the Data Environment you always first need to open the Data Environment to get to its code.
 
Last edited:
Hello GTGeek!

I let the Data Environment empty in the form (no table, no cursor, no view), and I used this approach and the result was ok:

Code:
WITH thisform
    .txtRCODI.Value=YRCODI
    .txtRNOME.Value=YRNOME
    .txtRCLAS.Value=YRCLAS
    .txtRVALI.Value=YRVALI
    .txtRARMA.Value=YRARMA
ENDWITH

WITH thisform.Pageframe1.Page1
    .txtRcust.Value=YRCUST
    .txtRrend.Value=YRREND
    .txtRunid.Value=YRUNID
    .txtRpper.Value=YRPPER
    .txtRpesu.Value=YRPESU
  
*   etc etc
ENDWITH

FOR X=1 TO 20
    strX=STR(X,2)
    IF SUBSTR(strX,1,1)=" "
        strX="0"+SUBSTR(strX,2,1)
    ENDIF
       
    frase="thisform.Pageframe1.Page1.txtRor"+strX+".Value"
    &frase=YROR(X)

    frase="thisform.Pageframe1.Page1.txtRco"+strX+".Value"
    &frase=YRCO(X)

*   etc etc
NEXT X
 
Hi GTG,

A view won't work?

They will ala they have been defined and parameterized - I have quite a lot of LOCAL VIEWS in my DEs. I guess, as Chrisss posted, that you can't CREATE them in the DE.


MarK
 

Part and Inventory Search

Sponsor

Back
Top