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!

"Record is in use" Err, w/ CRS Not TBL

Status
Not open for further replies.

SleepDepD

Programmer
Mar 13, 2004
65
US
I'm having problems with a class in my project that was written by someone else--base class: TextBox. It's worked fine when the ControlSource has been a field in a table, but now I'm trying to use it with a cursor. I'm getting the error: #109 - Record is in use by another user.

I'm sure this is related to my cursor being created with a CREATE CURSOR command and something about it that I'm not setting correctly. There are TABLEUPDATEs performed on the cursor, forwhich I'm using:

=CURSORSETPROP "Buffering",5,"crsMyCursor")"

after the CREATE CURSOR, but is there something else I need to set to make the cursor more like a table?

I've done some debugging on my cursor and table at runtime and found the following:
For CRS:
Sys(2011) [Current Lock Status] = "Exclusive"
ISFLOCKED=.T.

For TBL:
Sys(2011) = "Record Unlocked"
ISFLOCKED=.F.

Thank you.

...SLeeP-DeP'd
 
After you have created the cursor, did you APPEND BLANK or INSERT so there is a record to bind?

Regards,

Mike
 
I'm not sure what you mean. My cursor is created, and then later I use a USE IN "crsMyCursor" and SELECT...INTO CURSOR crsMyCursor READWRITE to add the correct records--once my form has been setup and my WHERE clause can be built.

Following the CREATE CURSOR command, I added APPEND BLANK IN "crsMyCursor"--however this had no effect.

Thanks for a quick response though.

...SLeeP-DeP'd
 
Hello SleepDepD.

It's worked fine when the ControlSource has been a field in a table, but now I'm trying to use it with a cursor. I'm getting the error: #109 - Record is in use by another user.

Is this text box, by any chance, beign used in a grid? If so, on which line of code is the error occurring?



Marcia G. Akins
 
Actually, I'm a bit confused about what you are trying to do. A cursor is created in memory so it would be exclusive by default and I have no idea why it would need to be buffered. Also, what would TABLEUPDATE write to?

Are you by chance using an updatable view based on a select from a table?

Regards,

Mike
 
In addition to working within the confines of a number of classes developed by other programmers in the course of a maybe-6 year project, I'm also fairly new to VFP and probably bastardizing a lot of the controls and programming methods...that being said.

MarciaAkins:
No, the subclassed TextBox is not contained in a Grid--but a GRD is involved. My form is actually a bunch of TXTs and CMBs driven by a GRD (populated from a cursor that's SQL'd from a few tables).

mspratt:
The reason I'm using a cursor is because my subclassed GRD doesn't behave well when RecordSource'ing tables...consequently, a number of other CLSs I'm using have to interact with this cursor--including one that handles the saving of data (via TABLEUPDATE() ).

I'm real sorry for the confusion; working with the code of several other people less-than-preferred'ly documented sucks all around--especially for the programmers on the forums I have to go to for help!

I guess what I'm really looking to do is shut off this "Exclusive"/"ISFLOCKED"-ness of the cursor so it'll work with my CLSs.

...SLeeP-DeP'd
 
I'm still a little confused about TABLEUPDATE used with a cursor unless the cursor is the result of a updatable view.

Regards,

Mike
 
Thanks everyone for your help.

I decided not to use some of the classes that were causing problems. I'll have to "reinvent the wheel" a little--but, it seems better than the alternative. Thanks again.

...SLeeP-DeP'd
 
MarciaAkins,
The error was occurring in the Refresh event of the class that contained the subclass'd TXT I was talking about:
Code:
PROCEDURE Refresh
THIS.txtMySubClass.Refresh()
THIS.txtMySubClass.Value = THIS.txtMySubClass.Value
ENDPROC
I removed that second line (I don't know why it was there in the first place) and it worked fine.

...SLeeP-DeP'd
 
Refresh() is valid with a view but not with a bare cursor.

Regards,

Mike
 
That's wrong, Mike. Refresh() is valid with a Textbox, no matter what it's bound to.


My cursor is created, and then later I use a USE IN "crsMyCursor" and SELECT...INTO CURSOR crsMyCursor READWRITE to add the correct records


There's your problem. When you run a SELECT into your cursor, you temporarily close the cursor. That pulls the rug out from under any control bound to it.

You could:

SELECT INTO (temp cursor)
SELECT (your txtbox's cursor)
ZAP
APPEND FROM (temp cursor)

IOW, don't close the control's data source. (A far better alternative would be a parameterized view.)
 
Hi Dan,

I stand corrected. I was probably thinking requery which would error on a bare cursor.

I would also agree about using a parameterized view.

Regards,

Mike
 
Hello SleepDepD

PROCEDURE Refresh
THIS.txtMySubClass.Refresh()
THIS.txtMySubClass.Value = THIS.txtMySubClass.Value
ENDPROC

None of that code is necessary. When the container that holds the textboxes is refreshed, the textboxes are also refreshed automatically. Refresh() is a method that is braodcast to all the controls inside a container.



Marcia G. Akins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top