Office中国论坛/Access中国论坛
标题:
如何根据登录的用户组选择可查看的记录集-窗体筛选
[打印本页]
作者:
tomsonliu
时间:
2008-10-5 17:20
标题:
如何根据登录的用户组选择可查看的记录集-窗体筛选
小弟在做一个程序,想根据登录后的用户名所属于的用户组,选择它可以查看的记录,用户组是根据部门的不同可查看的记录不同,需要在接下来的数个窗体间传递筛选,这些窗体的数据源或者是表或者是查询,如何实现?下文是小弟的代码,麻烦帮忙看看,谢谢
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
作者:
tmtony
时间:
2008-10-6 01:39
可在窗体main打开的open事件中 重设窗体的recordsource 来实现
作者:
tomsonliu
时间:
2008-10-6 16:33
可是我很多窗体控件属性设置的是从窗体的recordsource里边读取数据的,改了以后会不会那些控件就不能用了,或者出错,唉
试试先,
谢谢版主
作者:
tomsonliu
时间:
2008-10-6 17:21
版主,刚查了一下我的窗体设计,应该是在登录窗体后,打开新的窗体(含子窗体),然后在子窗体里边筛选
能不能在openform里边给子窗体添加筛选变量
作者:
david9198
时间:
2008-12-17 12:55
dddddddd
欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/)
Powered by Discuz! X3.3