×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Exclusive Table on Network

Exclusive Table on Network

Exclusive Table on Network

(OP)
Hi

When using a table on a network is there any way that I can check if the table is already being USEd by another user before I try to open it?

For example, to carry out housekeeping by PACKing a table to get rid of deleted records, I want to open the table for EXCLUSIVE use. If the table is already opened by another user I get an error when I try to USE it EXCLUSIVEly. Is there a way I can check this before trying to USE the table?

John

RE: Exclusive Table on Network

Hi
IF USED(myTable)
   ** The Table is open now
ELSE
   ** It is not used now
ENDIF

OR
lUsed = USED(myTable) && lUsed is .t. or .f.

ramani
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

RE: Exclusive Table on Network

Try this:

ON ERROR WAIT WINDOW "Someone has the table open" TIMEOUT 3
USE SomeFIle EXCLUSIVE
ON ERROR

Dave S.

RE: Exclusive Table on Network

John,
Actually, just like when trying to find out whether a record is locked and you have to do RLOCK(), opening a file EXCLUSIVE is similar - you have to try.

* save off current error handler
lcSvError = ON("error")
llNoProblem = .T.
ON ERROR llNoProblem = .F.
USE myfile EXCLUSIVE
* set it back to normal error handling
ON ERROR &lcSvError
IF llNoProblem
  MESSAGEBOX("Got file opened EXCLUSIVE")
ELSE
  MESSAGEBOX("File is in use")
ENDIF

Sorry, ramani, this time your code just won't accomplish what's needed. (I've gotten my share of answers wrong too ).

Rick

RE: Exclusive Table on Network

Hi Rick..
Little more enlightenment required.
I tried the codes myself, and I am getting correct
myTable below.. need to be a Character variable.. so to say... if Test.DBF then... USED("TEST").. This is giving .t. or .f. in my testing.

IF USED(myTable)
   ** The Table is open now
ELSE
   ** It is not used now
ENDIF

OR
lUsed = USED(myTable) && lUsed is .t. or .f.

ramani
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

RE: Exclusive Table on Network

HI
stumped !!!!!!!!!!!!!!!!!!
I understand.. this is a network situation.. opened by some one else. Not the same user...
You are right Rick.. My answer is not correct.
Thanks for pointing out.

ramani
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

RE: Exclusive Table on Network

That's OK, as you might guess the reason I knew that answer is that I'd been burnt by it before. Experience is a great teacher - it just "laughs" at you more than most of the helpful people here.

Congratulations on your "TipMaster of the Week" nomination - you deserve it.

Rick

RE: Exclusive Table on Network

(OP)
Thanks to everyone for their suggestions, especially Rick whose suggestion works fine!

I smiled to myself when I read Ramani's first suggestion as I realised he had missed the network part - although I am still always pleased to see a response from Ramani as he is a great help in sorting out everyone's problems!

John

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close