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:

 'DeclarationsPublic MyDB As DatabaseDim Dummy As Integer'Sample callsDummy = HardLockTable("UnLock", "TestTable")Dummy = HardLockTable("Lock", "TestTable")Function HardLockTable_	(ByVal whichAction As String, _	ByVal aTable As String) As IntegerOn Error GoTo HardLockTableError'Default returnHardLockTable = TrueSelect Case whichActionCase "Lock"	MyDB.TableDefs(aTable).ValidationRule = "True=False"	MyDB.TableDefs(aTable).ValidationText = _		"This table locked via " & _		"ValidationRule on " & NowCase "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 IfEnd SelectHardLockTableErrorExit:		'subFlushDBEngine		'optional, see next suggestionExit FunctionHardLockTableError:		HardLockTable = False		MsgBox Error$ & " error " & _			"in HardLockTable trying " & _			"to " & whichAction & " " & _			aTable		Resume HardLockTableErrorExitEnd Function
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS