Reputation: 1
How to display a username on the top left corner.The user will be login on the login form after that when he enter the menu. Is there a way to display what is his username on the top left corner using textbox ? (Using VBA)
My Current Code
Dim Name As String
Name = DLookup("FullName", "tblIC", "frmlog.txtIC.value=" & "IC")
Me.txtName.value = Name
The Code doesn't work. Im trying to write a code in FrmMenu textbox to dlookup from Frmlog. As in FrmLog the user will enter their UserName then in FrmMenu the top left corner will show their full name and userid.
How do i dlookup so that it will use the requirement in FrmLog for FrmMenu ?
Upvotes: 0
Views: 54
Reputation: 3399
You can use for example the DLookup()
function on the load event of the form if the user name is in a table:
Dim userName As String
userName = DLookup("ColumnName", "YourTableName", "YourCriteria = 1")
Me!UserNameTextbox.Value = userName
Another mehtod to get the username direct from the pc environment would be:
Dim userName As String
userName = Environ("USERNAME")
Upvotes: 0