Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-19-2019, 04:07 AM   #1
SetanPutih
Newly Registered User
 
Join Date: Jun 2019
Posts: 26
Thanks: 14
Thanked 0 Times in 0 Posts
SetanPutih is on a distinguished road
Hide Admin Button

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.

SetanPutih is offline   Reply With Quote
Old 07-19-2019, 04:27 AM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 3,599
Thanks: 38
Thanked 875 Times in 858 Posts
theDBguy will become famous soon enough theDBguy will become famous soon enough
Re: Hide Admin Button

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.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is offline   Reply With Quote
Old 07-19-2019, 06:47 PM   #3
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 14,077
Thanks: 81
Thanked 1,600 Times in 1,484 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
Re: Hide Admin Button

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.

__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.
The_Doc_Man is offline   Reply With Quote
Old 07-19-2019, 08:12 PM   #4
Micron
Newly Registered User
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 797
Thanks: 10
Thanked 161 Times in 155 Posts
Micron will become famous soon enough Micron will become famous soon enough
Re: Hide Admin Button

I read it 3 times and still don't know what the issue is?
The lookup syntax doesn't look right; maybe

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

__________________
Sometimes I just roll my eyes out loud...
Windows 10; Office 365 (Access 2016)
Micron is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
admin button module help gmc2k2 Modules & VBA 5 02-03-2014 08:07 AM
[SOLVED] Hide button RonnieODIN Modules & VBA 3 06-19-2013 03:22 AM
Admin lost admin rights pne987 General 1 07-30-2002 08:14 AM
command button visible if security group = [admin] MSUKevin Forms 4 09-07-2001 07:18 AM




All times are GMT -8. The time now is 11:57 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World