Hide Admin Button (1 Viewer)

SetanPutih

Registered User.
Local time
Today, 14:19
Joined
Jun 27, 2019
Messages
27
Hi,

Hope someone can help. I've built an employee database with a login system. What I'm trying to do is, when someone logs in with the name Admin a button becomes visible on the window which the login window leads too which would not be visible to everyone else. The button will be called Admin. The login code I have so far is..

Option Compare Database

Private Sub cmdLogin_Click()
Dim strID As String
strID = DLookup("[EmployeeID]", "Employees", "[UserName]='" & Me.cboUser.Column(1) & "" & "' And Password = '" & Me.txtPassword & "" & "'") & ""
If strID <> "" Then
gEmployeeID = strID
Forms!Form1!lblWelcome.Caption = "Welcome " & Me.cboUser.Column(1) & " " & Me.cboUser.Column(2)

DoCmd.Close acForm, Me.Name

Else
MsgBox "Invalid User or Password. Please try again.", vbInformation + vbOKOnly

End If
End Sub

Private Sub Form_Close()
If gEmployeeID = "" Then Application.Quit
End Sub


Thanks for reading.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:19
Joined
Oct 29, 2018
Messages
21,358
Hi. One approach is to not close your login form but merely hide it so you can always refer to the user information when you need it. Either that or save the info into global variables or TempVars.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 16:19
Joined
Feb 28, 2001
Messages
27,001
To help you find some articles on this subject, try doing an in-forum search using "user role" as a search target. The SEARCH option is in the thin menu bar/ribbon near the top of each page, just under the box that shows you your logged-in username.
 

Micron

AWF VIP
Local time
Today, 17:19
Joined
Oct 20, 2018
Messages
3,476
I read it 3 times and still don't know what the issue is? :confused:
The lookup syntax doesn't look right; maybe

Code:
strID = DLookup("[EmployeeID]", "Employees", "[UserName]='" & Me.cboUser.Column(1) & "' And Password = '" & Me.txtPassword & "'")
 

Users who are viewing this thread

Top Bottom