access突然需要登录_Microsoft Access中 - 中登录的用户名来自用户的显示名

bd96500e110b49cbb3cd949968f18be7.png

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.

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?

Thanks

解决方案

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

SELECT ID, userNameField

FROM EmpAuth;

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;

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

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值