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!

cannot zap a cursor

Status
Not open for further replies.

vj

Programmer
Nov 18, 2000
58
MU
hi guys,

i have defined a cursor in the init event of my form .. and have set it as RECORDSOURCE to one of the grid control in my form... then somewhere in between while iam on the form ... i need to zap that cursor ... but i get this message "File is open in another work area" ... does anyone know how i can handle this ... ?

thankx
Vijay
 
Based on what you've told us, I can't see any obvious reason for that. You must be doing something else with the cursor that you haven't mentioned. Can you tell us more exactly what you are doing? Where exactly are you setting the RecordSource? And at what point are you doing the zap?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 

Mike ,

iam just doing the usual thing .. append or edit records

This is in the init event :
---------------------------
CREATE CURSOR CURS_PURCHASE -- [structure]
SELECT CURS_PURCHASE
GOTO TOP
THISFORM.GRD_PURCHASE.RECORDSOURCE=DBF('CURS_PURCHASE')
THISFORM.GRD_PURCHASE.REFRESH()

Then i do something in some buttons click :
-------------------------------------------
SELECT MAX(ITEM) AS MAXPO FROM CURS_PURCHASE INTO CURSOR MAXPO
INSERT INTO CURS_PURCHASE -- [some values]

This is in another buttons click :
----------------------------------
SELECT CURS_PURCHASE
ZAP

i get the same message "File is open in another work area" even when i just start the form and the only thing i do is zap !

 
Vijay,

OK, I can see what's happening.

The problem is that you are using the DBF() function when setting the record source:
[tt]
THISFORM.GRD_PURCHASE.RECORDSOURCE=DBF('CURS_PURCHASE')[/tt]

And you probably have the RecordSourceType set to 0. So VFP has opened a new instance of the cursor, hence the error message.

You need to do this:

[tt]THISFORM.GRD_PURCHASE.RecordSourceType = 1
THISFORM.GRD_PURCHASE.RecordSource = "Curs_Purchase" && NOT DBF("Curs_Purchase")[/tt]

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
hmmm ... ok .. i'll try to do it .. well usually even i use to set the recordsourcetype = 1 and recordsource="cursor name" but sometimes i noticed that when i refresh or manipulate the data in the cursor and refresh the grid .. the columns of the grid re-size ... but then when i tried the recordsourcetype=0 and trecordsource=dbf('cursor name') ... the grid columns seem to be stable ( the way i had set them up in design time ) !!! have you had the same problem ??

Thankx alot
Vijay
 
I have just reproduced your form, using your original code. When I set the RecordSourceType to 0 and the RecordSource to the DBF() value, I see the same error message you saw. But when I do it my way, it works perfectly.

I would guess that the problem of the grid columns being resized in not related.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
i'v done it too .. the error msg is gone .. thankx for that ..... but i was just giving you additional info about the columns getting re-sized .. which i'v noticed when i use without the dbf('cursor name') and grid recordsourcetype=1

thankx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top