【顯示隱藏導(dǎo)航窗格】【向組合框添加選項(xiàng)】【修改密碼驗(yàn)證功能】
顯示隱藏導(dǎo)航窗格
Public hidden_num As Integer
Private Sub Command隱藏_Click()
If hidden_num = 0 Then
hidden_num = 1
DoCmd.SelectObject acForm, , True
DoCmd.RunCommand acCmdWindowHide
Else
hidden_num = 0
DoCmd.SelectObject acForm, , True
End If
End Sub
向組合框添加選項(xiàng)
Private Sub Command刪除_Click()
If Me.城市列表 <> "" Then
? ? DoCmd.SetWarnings (False)
? ? Dim del_sql As String
? ? del_sql = "Delete From 城市表 Where? 城市名稱= '" & Me.城市列表 & "'"
? ? DoCmd.RunSQL del_sql
? ? Me.城市列表.Value = ""
? ? Me.城市列表.Requery
Else
MsgBox "請(qǐng)選擇要?jiǎng)h除的城市"
End If
End Sub
Private Sub Command添加_Click()
If Me.添加城市名 <> "" Then
? ? If Nz(DCount("城市名稱", "城市表", "城市名稱='" & Me.添加城市名 & "'"), 0) > 0 Then
? ? ? ? MsgBox "城市名已存在"
? ? ? ? Exit Sub
? ? End If
? ? DoCmd.SetWarnings (False)
? ? Dim add_sql As String
? ? add_sql = "Insert Into 城市表 (城市名稱) Values ('" & Me.添加城市名 & "')"
? ? DoCmd.RunSQL add_sql
? ? Me.城市列表.Requery
Else
MsgBox "城市名不能為空"
End If
End Sub
修改密碼驗(yàn)證功能
Private Sub Command修改密碼_Click()
Dim oldpw As String
Dim newpw As String
oldpw = InputBox("請(qǐng)輸入原密碼")
If oldpw <> Me.密碼 Then
MsgBox "原密碼不正確"
Exit Sub
End If
newpw = InputBox("請(qǐng)輸入新密碼")
If newpw <> "" Then
? ? If newpw = oldpw Then
? ? ? ? MsgBox "新密碼不能與舊密碼相同"
? ? ? ? Exit Sub
? ? End If
? ? If Len(newpw) < 6 Then
? ? ? ? MsgBox "新密碼不能小于6位"
? ? ? ? Exit Sub
? ? End If
? ? Me.密碼 = newpw
? ? MsgBox "密碼修改成功"
Else
MsgBox "新密碼不能為空"
Exit Sub
End If
End Sub