📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "锁住和解锁数据库"
ClientHeight = 3690
ClientLeft = 60
ClientTop = 345
ClientWidth = 4530
LinkTopic = "Form1"
ScaleHeight = 3690
ScaleWidth = 4530
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "取消锁定"
Height = 450
Left = 2805
TabIndex = 4
Top = 1185
Width = 1320
End
Begin VB.CommandButton Command2
Caption = "锁定"
Height = 450
Left = 2805
TabIndex = 3
Top = 630
Width = 1320
End
Begin VB.ListBox List1
Height = 2400
Left = 225
TabIndex = 1
Top = 375
Width = 2100
End
Begin VB.CommandButton Command1
Caption = "退出"
Height = 450
Left = 2790
TabIndex = 0
Top = 2625
Width = 1320
End
Begin VB.Label Label2
Height = 825
Left = 195
TabIndex = 5
Top = 2820
Width = 2145
End
Begin VB.Label Label1
Caption = "数据库列表"
Height = 330
Left = 300
TabIndex = 2
Top = 75
Width = 2010
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim db As Database
Dim tb As TableDef
Private Sub Form_Load()
Set db = OpenDatabase(App.Path & "\sj.mdb", False, False, ";pwd=111")
For Each tb In db.TableDefs
If Left(tb.Name, 4) <> "MSys" Then List1.AddItem (tb.Name)
Next
List1.Refresh
End Sub
Private Sub Command2_Click()
db.TableDefs(List1.Text).ValidationRule = "True=False"
db.TableDefs(List1.Text).ValidationText = "This table locked via " & "ValidationRule on " & Now
Label2.Caption = List1.Text & " 已被锁定,您将无法修改数据!"
End Sub
Private Sub Command3_Click()
db.TableDefs(List1.Text).ValidationRule = ""
db.TableDefs(List1.Text).ValidationText = ""
Label2.Caption = List1.Text & " 已解除锁定,您可以修改数据! "
End Sub
Private Sub List1_Click()
If db.TableDefs(List1.Text).ValidationRule = "True=False" Then
Label2.Caption = List1.Text & " 是被锁定的表"
Else
Label2.Caption = List1.Text & " 表没被锁定"
End If
End Sub
Private Sub Command1_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -