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!

how to get data into a cursor from grid in foxpro?

Status
Not open for further replies.

Niki_S

Programmer
Jun 4, 2021
232
LK
I have a grid as Grid1 and the columns are as below.
Code:
Stylecode     OrderQty     ReceiveQty
CD123         100          75
NHG345        125          125
JK87          500          200

Now I want to do something like this. When I'm selecting a row from my grid I want to take that row data into a cursor. As an example if I select 1st Row I want to get Stylecode, OrderQty, ReceiveQty into a cursor as below.

Code:
Stylecode     OrderQty     ReceiveQty
CD123         100          75

How can I do this?

Thank you
 
That could perhaps be done with a method on the OnRowColChange event.
In the snippet below I'm copying the data to a temporary table (sited in the folder
specified in m.Tempdir such as c:\temp\myapp\) but you could use a SQL statement to
put it into a cursor instead.

Code:
IF USED("myCursor")
	SELECT myCursor
	USE
ENDIF
SELECT myTable
COPY TO (m.TempDir+"myCursor") NEXT 1
SELECT 0
USE (m.TempDir+"myCursor")
SELECT myTable

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

There is no place like G28 X0 Y0 Z0
 
Code:
Local lnRecno
lnRecno=Recno()
SELECT * FROM (Thisform.Grid1.Recordsource) WHERE RECNO() = lnRecno

Which assumes the Grid1 is a) directly on the form and b) has an alias as recordsourcetype.

If the grid recordsourcetype is something different, please describe what it is.

Chriss
 
I do have one question, though. What is the goal of having that row in a separate cursor? You can always access the current row just by field names, I seeno need for a separate cursor.

You can also use SCATTER or SCATTER TO NAME to put the values of the current records into variables or a single object variable, which will have Stylecode, OrderQty, and ReceiveQty as properties. And such an object or single variables can be passed on to a second form, even if it has its own private data session. Besides, you could also just pass on the RECNO().

Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top