把表达式True=False放到表的ValidationRule属性就能锁上。HardLockTable?实现了该功能。 声明 PublicMyDBAsDatabase DimDummyAsInteger 函数 FunctionHardLockTable(ByValwhichActionAsString,?ByValaTableAsString)AsInteger OnErrorGoToHardLockTableError HardLockTable=True SelectCasewhichAction Case"Lock" MyDB.TableDefs(aTable).ValidationRule="True=False" MyDB.TableDefs(aTable).ValidationText=?"Thistablelockedvia"&?"ValidationRuleon"&Now Case"UnLock" MyDB.TableDefs(aTable).ValidationRule="" MyDB.TableDefs(aTable).ValidationText="" Case"TestThenUnLock" IfMyDB.TableDefs(aTable).ValidationRule="True=False"Then MyDB.TableDefs(aTable).ValidationRule="" MyDB.TableDefs(aTable).ValidationText="" EndIf EndSelect HardLockTableErrorExit: 'subFlushDBEngine 'optional,seenextsuggestion ExitFunction HardLockTableError: HardLockTable=False MsgBoxError$&"error"&"inHardLockTabletrying"&"to"&whichAction&""&aTable ResumeHardLockTableErrorExit EndFunction 使用例子 '上锁 Dummy=HardLockTable("Lock","TestTable") '开锁 Dummy=HardLockTable("UnLock","TestTable")->
|