Admin to create admin

Prashant

Registered User.
Local time
Tomorrow, 04:36
Joined
Nov 13, 2013
Messages
34
Hi,

I have been given to build a database which should have a login form with username and password, upon filling up the correct details a new form should open for e.g. main menu. Now if the logged in person is Admin, all the command buttons will be enabled, but if it user there are specific cmmd buttons which should be disabled.

I have already created the Login form based on the list filled in the table. The problem is I have enabled / disabled the cmd buttons based on the windows login ID which I have mentioned in the module in the Main Menu form. What I want is that it should detect based on the list of persons in the table against which the level is mentioned i.e. if Admin is should enable all the cmmd buttn or if User it should disable certain cmmd btns.

I also want a form where the Admin can given Admin Rights to a new or existing user.

Can anyone Help me on the same.

Thanks in Advance.
 
Last edited:
Hello Prashant, what is the code you have in the main form?
 
Hi Paul,

Below is the code I have used to disable the cmmd button

Private Sub Form_Current()
Command94.Enabled = (Me.Text72 = "ms185336") Or (Me.Text72 = "pb185101") Or (Me.Text72 = "gm185125")
Command99.Enabled = (Me.Text72 = "ms185336") Or (Me.Text72 = "pb185101") Or (Me.Text72 = "gm185125")
End Sub


Me.text72 is the field which captures the windows login ID.

Below is the code for the LOGIN FORM

rivate Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
Me.cboEmployee.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
'Check value of password in tblEmployees to see if this matches value chosen in combo box
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value) Then
lngMyEmpID = Me.cboEmployee.Value
'Close logon form and open splash screen

DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "Main Menu"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If

'If User Enters incorrect password 3 times database will shutdown

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 2 Then
MsgBox "You do not have access to this database. Please contact Support Team.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
 
Hi Paul,

I have solved the same, using the below logic :

I have used a text box (hidden) and done a dlookup with the table to identify whether userid is either User or Admin, based on the same I have enabled the command button.

Code:
Private Sub Form_Open(Cancel As Integer)
strAccess = DLookup("strAccess", "tblemployees", "strEmpName='" & [Text72] & "'")
Command94.Enabled = (Me.strAccess = "Admin")
Command99.Enabled = (Me.strAccess = "Admin")
End Sub
 

Users who are viewing this thread

Back
Top Bottom