|
-
Feb 8th, 2006, 11:52 AM
#1
Thread Starter
Fanatic Member
Exclusively Lock Table
I am trying to lock a table so that no one can edit it while its open.
This is in VBA using MS Access 2002.
I am opening my table as follows, as long as this table is open I want it locked.
VB Code:
'Connect to recordset
Set Db = dbEngine.Workspaces(0)(0)
Set RstImport = Db.OpenRecordset("SELECT * FROM " & dbTable)
And how do I check if the table is locked because if its locked I want to prompt the user "Hey this table is locked!"
Thanks
-
Feb 9th, 2006, 04:12 AM
#2
Re: Exclusively Lock Table
Depends how you are getting data to the screen. If via code you should get an error whilst attempting to open the recordset OR whilst trying to save the data change.
Most people are trying not to get the tables locked so I'm not sure if there is a property on the recordset you open that says state=locked. ADO might have one, which you can check.
Other alternative would be a field that says the record is locked by a user and time/date they did that. But you may need to use a clear query (Update) to reset those that are more than 12 hrs old for those users that forget to unlock/release the record(s).
Another alternative is to hold the live record and have an audit trail of previous records data. The user can then see a history of all the changes, who did them and when...
Edit:
You can use error ignoring/handling
Code:
on error resume next
set rst = db.openrecordset("sql statement")
if err.number=0 then
'---- no error
else
'---- error (locked?)
end if
Last edited by Ecniv; Feb 9th, 2006 at 04:21 AM.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|