下面是偶做的方法
先创建一个用户表,里面有用户名葛密码,,,然后弄两个文本框,一个名为name,一个为名为password 在登录按钮用VBA代码,代码如下:
If IsNull(Me![name]) Then
MsgBox “请选择用登录用户!”, 64, “系统提示”
Me![name].SetFocus
Else
If IsNull(Me![password]) Then
MsgBox “请输入密码,密码不能为空!”, 64, “系统提示”
Me![password].SetFocus
Else
Dim stemp As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
stemp = “select * from 用户表 where 用户名=” & Me![name] & “‘”
rs.Open stemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If rs(“密码”) <> Me![password] Then
MsgBox “密码错误,请重新输入!”, vbOKOnly, “系统提示”
Me![password] = “”
Me![password].SetFocus
Else
DoCmd.Close
DoCmd.OpenForm “主菜单”
End If
End If
End If