I have a login form built in Microsoft Access. The User will login through it and make it to the MainMenu form.
How do we put the Welcome "Username" on the MainMenu form? ( Not PC UserName)
User123
Password : 12345
On Mainmenu wil be KiranaWyn
I use below VBA
Code:
Option Compare Database
Private Sub Command1_Click()
Dim ID As Integer
Dim TempUserID As TempVar
If IsNull(Me.txtLoginID) Then
MsgBox "Enter the username", vbInformation, "Login ID required"
Me.txtLoginID.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "Enter password", vbInformation, "Password required"
Me.txtPassword.SetFocus
Else
If (IsNull(DLookup("UserID", "tblUser", "UserLogin = '" & Me.txtLoginID.Value & "' And password = '" & Me.txtPassword.Value & "'"))) Then
MsgBox "Invalid Login ID or Password!"
Else
ID = DLookup("[Userid]", "tblUser", "[UserLogin] = '" & Me.txtLoginID.Value & "'")
TempVars!TempUserID = ID 'assign user login ID to tempvar
DoCmd.Close
DoCmd.OpenForm "MainMenu"
End If
End If
End Sub
Private Sub Form_Load()
Me.txtLoginID.SetFocus End Sub