借用江羽的函数:
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
演 示: