Microsoft Access中 - 中登录的用户名来自用户的显示名 [英] Microsoft Access - Show name of logged in user from UserID

查看:1090
本文介绍了Microsoft Access中 - 中登录的用户名来自用户的显示名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Access数据库我正在里面有包括一个下拉(组合)菜单中选择用户名,密码字段和用户表的简单登录系统。

I have an Access database I'm working on which has a simple login system consisting of a drop down (combo) menu to select the username, a password field and a users table.

在用户表,我存储的用户名,密码,所有用户的名字。我已经成功地让我的登录表单的工作,但我想用户的名字下一个表单上显示在文本框中。

Inside the users table, I'm storing the username, password and the first name of all the users. I've managed to get my login form working, but I'd like the user's first name to be displayed in a text box on the next form.

我已经成功地获得用户的ID号,并在文本框中显示出来,但我一直没能得到用户的名字。

I've managed to get the user's ID number, and display it in a text box, but I haven't been able to get the user's first name.

有谁知道一个简单的方法,在文本框中显示用户的名字,记住我将有几种形式,我想显示用户的名字?

Does anyone know of a simple way to display the user's first name in a text box, keeping in mind I'll have several forms where I wish to display the user's first name?

感谢

推荐答案

随着你的描述说,您使用的是组合框,我肯定行来源会。

As your description says you are using a ComboBox, I am sure the RowSource would be.

SELECT ID, userNameField
FROM EmpAuth;

组合框属性绑定列 - 1,列计数 - 2,列宽 - 0厘米;2.5厘米(这样的事情,但可以肯定0厘米)。现在,所有你需要做的就是,做如下修改,行来源:

The ComboBox properties are Bound Column - 1, Column Count - 2, Column Widths - 0cm;2.5cm (something like this, but 0cm for sure). Now all you have to do is, make the following changes, RowSource :

SELECT ID, userNameField, firstNameField
FROM EmpAuth;

组合框属性绑定列 - 1,列计数 - 3,列宽 - 0厘米;2.5厘米**;0厘米**

ComboBox properties are Bound Column - 1, Column Count - 3, Column Widths - 0cm;2.5cm**;0cm**

然后,你可以简单地使用OpenArgs方法,你可以通过组合框列3.喜欢,

Then, you can simply use the OpenArgs method where you can pass the ComboBoxes Column 3. like,

If Me.password.Value = DLookup("password", "EmpAuth", _
        "[ID]=" & Me.username.Value) Then

    ID = Me.username.Value

    DoCmd.OpenForm "POSMenu", OpenArgs:=Me.username.Column(2) 
    'Close logon form and open splash screen
    DoCmd.Close acForm, "AuthenticationService", acSaveNo


Else
  MsgBox.............

然后终于在第二个窗体的加载事件,您可以使用。

Then Finally in the Second Form's On Load event you can use.

Private Sub Form_Load()
    If Len(Me.OpenArgs & vbNullString) > 0 Then _
        Me.yourTextBoxName = Me.OpenArgs
End Sub

希望这有助于。

Hope this helps.

这篇关于Microsoft Access中 - 中登录的用户名来自用户的显示名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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