dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 6, 1997

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Hard-Lock a Table

In many applications, I want to make absolutely sure that the data in a Jet table doesn't get modified under any circumstances. I hard-lock the table in addition to using any system-level security to protect it. Also, this hard lock stays with the MDB if it is issued with an application. Place the expression True=False into the ValidationRule property of the table to lock it. The Jet evaluates this expression to False and blocks updates to the table:
 
'Declarations
Public MyDB As Database
Dim Dummy As Integer
'Sample calls
Dummy = HardLockTable("UnLock", "TestTable")
Dummy = HardLockTable("Lock", "TestTable")
Function HardLockTable_
	(ByVal whichAction As String, _
	ByVal aTable As String) As Integer
On Error GoTo HardLockTableError
'Default return
HardLockTable = True
Select Case whichAction
Case "Lock"
	MyDB.TableDefs(aTable).ValidationRule = "True=False"
	MyDB.TableDefs(aTable).ValidationText = _
		"This table locked via " & _
		"ValidationRule on " & Now
Case "UnLock"
	MyDB.TableDefs(aTable).ValidationRule = ""
	MyDB.TableDefs(aTable).ValidationText = ""
Case "TestThenUnLock"
	If MyDB.TableDefs(aTable)._
		ValidationRule = "True=False" Then
			MyDB.TableDefs(aTable).ValidationRule = ""
			MyDB.TableDefs(aTable).ValidationText = ""
	End If
End Select
HardLockTableErrorExit:
		'subFlushDBEngine
		'optional, see next suggestion
Exit Function
HardLockTableError:
		HardLockTable = False
		MsgBox Error$ & " error " & _
			"in HardLockTable trying " & _
			"to " & whichAction & " " & _
			aTable
		Resume HardLockTableErrorExit
End Function
Stan Mlynek
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date