Alhakeem1977
Registered User.
- Local time
- Today, 06:18
- Joined
- Jun 24, 2017
- Messages
- 308
Hi All,
I am using the below code to identify the current user in the main form [NavigationForm] but I realized that the users are facing a little delay while launching the system.
I am using in my code the DLookup function on Open event to achieve that, I heard about the Recordset and TempVars, I do not know how to use them if they are faster than DLookup.
I would be grateful if someone can guide me to use the best approach to achieve that.
Here is my code:
I am using the below code to identify the current user in the main form [NavigationForm] but I realized that the users are facing a little delay while launching the system.
I am using in my code the DLookup function on Open event to achieve that, I heard about the Recordset and TempVars, I do not know how to use them if they are faster than DLookup.
I would be grateful if someone can guide me to use the best approach to achieve that.
Here is my code:
Code:
Private Sub Form_Open(Cancel As Integer)
On Error Resume Next
DoCmd.OpenForm "frmLogo", acNormal
DoCmd.Maximize
DoCmd.OpenForm "LoginForm", acNormal
DoCmd.ShowToolbar "ribbon", acToolbarNo
'****************************************
Me.txtUserID = Environ("Username")
Me.txtDeptID = DLookup("ID", "qryUserLog_Dept", "[UserLogin] = '" & Environ("UserName") & "'")
Me.txtUserName = DLookup("UserName", "tblUser", "[UserLogin]='" & Environ("UserName") & "'")
Me.txtID = DLookup("UserID", "tblUser", "[UserLogin]='" & Environ("UserName") & "'") 'User ID Number
Me.txtLastName = DLookup("LastName", "tblUser", "[UserLogin]='" & Environ("UserName") & "'")
Me.txtDeptShN = DLookup("DeptShName", "qryUserLog_Dept", "[UserLogin] = '" & Environ("UserName") & "'")
End Sub
Thanks in advance!