根据用户隐藏“访问导航表单”按钮 [英] To hide Access Navigation Form buttons depending on User

查看:63
本文介绍了根据用户隐藏“访问导航表单”按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了安德烈·阿尔特米耶(Andrey Artemye)的以下代码,正如他所说的那样对我有用..

I have found the following code by Andrey Artemye and it worked for me exactly as he said..


Public
Function ADtest()
As
字符串


Dim ADSI
As
对象 ,UN
As
对象


 
设置 ADSI = CreateObject( " ADSystemInfo"


 
设置 UN = GetObject( " LDAP://"
& ADSI.UserName )


 
ADtest = UN.FirstName

  ADtest = UN.FirstName


 
ADtest = ADtest&
"" & UN.LastName

  ADtest = ADtest & " " & UN.LastName


 
设置 UN =
没什么


 
设置 ADSI =
没什么


结束
功能


我是VBA的新用户但是我想在我创建的访问导航表单上使用此代码表单上有四个按钮(用于那一刻)我怎样才能使用上面的代码来隐藏一些依赖于用户名的按钮。 

I am new to VBA but I would like to use this code on an access Navigation form I have created The form has four buttons on it (for the moment) How can I use the above code to hide some of the buttons dependant on the user name. 

我想我必须创建一个用户表并运行一个查询如何使用vba集成查询是我需要帮助的地方

I guess I would have to create a table of users and run a query. How to integrate the query using vba is where I need help

推荐答案

您是否测试过上述代码并且有效?

Have you tested the above code and it works?

我不会担心用户的实际名称,而是简单地使用系统指定的用户名。

I tend not to worry about the user's actual names but rather simply use the username as assigned by the system.

您可以使用上面的(我猜)获取用户名,或者您可以尝试
此方法

You can get the username using the above (I guess) or you can try this method.

要检查当前用户是否已获得授权,您需要将其权限存储在表中然后,您可以使用DLookup()或DCount()进行验证用户。

To check if the current user is authorized, you will need to store their permissions in a table. You can then use DLookup() or DCount() to verify the user.

例如:

如果DCount(" *"," tblUsers"," UserName ='" &安培;用户名()& "''")> 0然后

 '授权用户

否则

 '未授权

结束如果

If DCount("*", "tblUsers", "UserName='" & Username() & "'") > 0 Then
 'authorized user
Else
 'not authorized
End If

希望它有所帮助......

Hope it helps...


这篇关于根据用户隐藏“访问导航表单”按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆