Access数据库培训
网站公告
·Access快速平台QQ群号:277422564    ·Access快速开发平台下载地址及教程    ·欢迎添加微信交流账号:Accessoft7    ·如何快速搜索本站文章|示例|资料!    
您的位置: 首页 > 技术文章 > Access数据库-窗体/数据页

Inputbox密码打开窗体/输入密码打开窗体

时 间:2012-11-17 22:18:53
作 者:网行者   ID:12122  城市:江门
摘 要:Inputbox密码打开窗体
正 文:

借用江羽的函数:

http://www.accessoft.com/article-show.asp?id=2743

Option Compare Database

Public Declare Function findwindow Lib "user32" Alias "FindWindowA" (ByVal lpclassname As String, ByVal lpwindowname As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function timeSetEvent Lib "winmm.dll" (ByVal uDelay As Long, ByVal uResolution As Long, ByVal lpFunction As Long, ByVal dwUser As Long, ByVal uFlags As Long) As Long
Public Declare Function timeKillEvent Lib "winmm.dll" (ByVal uID As Long) As Long
Public Const EM_SETPASSWORDCHAR = &HCC
Public lTimeID As Long

'timeSetEvent的回调函数
Sub TimeProc(ByVal uID As Long, ByVal uMsg As Long, ByVal dwUser As Long, ByVal dw1 As Long, ByVal dw2 As Long)
'捕捉inputbox
    hwd = findwindow("#32770", "密码输入")
    If hwd <> 0 Then
        hwd = FindWindowEx(hwd, 0, "edit", vbNullString)
        SendMessage hwd, EM_SETPASSWORDCHAR, 42, 0
        timeKillEvent lTimeID
    End If
End Sub


'我的自定义函数

Public Function passwordOpenForm(myFrm As String)
    Dim myInput As String
    Dim M_ad As Boolean

    lTimeID = timeSetEvent(10, 0, AddressOf TimeProc, 1, 1)
    myInput = InputBox("请输入管理密码:", "密码输入")

    If IsNull(myInput) or DCount("工号", "usysuser", "密码 = '" & myInput & "'") = 0 Then
        MsgBox "未输入密码或密码错误!", vbOKOnly + vbCritical, "系统提示"
        DoCmd.Close acForm, myFrm
    Else
        M_ad = DLookup("管理员", "usysuser", "密码 = '" & myInput & "'")
        If M_ad Then
            MsgBox "欢迎你,系统管理员!", vbOKOnly + vbInformation, "系统提示"
        Else
            MsgBox "您不是管理员!", vbOKOnly + vbCritical, "系统提示"
            DoCmd.Close acForm, myFrm
        End If
    End If
End Function


窗体加载事件中调用:

Private Sub Form_Load()
On Error GoTo Err_Form_Load

    passwordOpenForm ("frmSetPermissions")

Exit_Form_Load:
    Exit Sub
Err_Form_Load:
    MsgBox Err.Description
    Resume Exit_Form_Load
End Sub


附   件:

点击下载此附件

帐户号:000001,密码:000001


演   示:



Access软件网QQ交流群 (群号:86789465)       access源码网店

最新评论 查看更多评论(5)

2019/5/11 11:56:06假球迷
收藏了,谢谢

2012/11/21 19:15:55麥田
哈哈 

2012/11/21 18:39:07网行者
麦田老师开玩笑了。
好吧,送佛送到西,把图片、示例附上,供初学者参考。

2012/11/20 21:27:14麥田
就是改密码有点繁琐  

2012/11/20 13:20:35麥田

发表评论您的评论将提升作者分享的动力!快来评论一下吧!

用户名:
密 码:
内 容:
 

常见问答

技术分类

相关资源

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助