鎖住數據庫中的表

發表于:2007-07-14來源:作者:點擊數: 標簽:
把表達式 True=False 放到表的 ValidationRule 屬性就能鎖上。 HardLockTable?實現了該功能。 聲明 Public MyDB As Database Dim Dummy As Integer 函數 Function HardLockTable (ByVal whichAction As String,?ByVal aTable As String) As Integer On Error
把表達式 True=False 放到表的 ValidationRule 屬性就能鎖上。 HardLockTable?實現了該功能。
聲明
Public MyDB As Database
Dim Dummy As Integer
函數
Function HardLockTable (ByVal whichAction As String,?ByVal aTable As String) As Integer
On Error GoTo HardLockTableError
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
使用例
'上鎖
Dummy = HardLockTable("Lock", "TestTable")
' 開鎖
Dummy = HardLockTable("UnLock", "TestTable") 

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97