|
小弟在做一个程序,想根据登录后的用户名所属于的用户组,选择它可以查看的记录,用户组是根据部门的不同可查看的记录不同,需要在接下来的数个窗体间传递筛选,这些窗体的数据源或者是表或者是查询,如何实现?下文是小弟的代码,麻烦帮忙看看,谢谢
Dim Temp As String
If IsNull(Me![Combo_UserName]) Or IsNull(Me![Text_password]) Then
MsgBox "您输入的用户名和密码不能为空,请重新输入!", vbOKOnly, "注意"
Else
Dim conString As ADODB.Connection
Set conString = New ADODB.Connection
conString.Open "×××××××××××××××××××
Dim username, password As String
username = Combo_UserName.Value
password = Text_password.Value
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Temp = "Select * From user_list where 姓名='" & username & "'and 密码='" & password & "'"
rs.Open Temp, conString, adOpenKeyset, adLockOptimistic, -1
If rs.RecordCount > 0 Then
Dim div As String
div = rs.Fields("部门")
DoCmd.Close
DoCmd.OpenForm "main", acNormal, "", div, acFormEdit, acWindowNormal
````````````````````````````````````````````````````````````````````````````````````````````````````````````````
这一句搞不对~~
rs.Close
Set rs = Nothing |
|