Originally Posted by
foxtet
Hi Khalid;
Thank for the reply
I still find it difficult to make command buttons enable/disable based on the login. hence i attach the login file for your review. I need your help.
Thank you.
foxtet
Hi foxtet,
sorry for late reply, my net was out of order. I downloaded your db and created a login button with little changes in your code here is the full code: new code lines are highlighted
Code:
Option Compare Database
Private Sub cboUser_AfterUpdate()
Me.cmdOpenMain.Enabled = False
Me.txtPassword = ""
End Sub
Private Sub cmdOpenMain_Click()
DoCmd.OpenForm "frmMain"
Me.Visible = False
End Sub
Private Sub txtPassword_AfterUpdate()
'Check that EE is selected
If IsNull(Me.cboUser) Then
MsgBox "You need to select a user!", vbCritical
Me.cboUser.SetFocus
Else
'Check for correct password
If Me.txtPassword = Me.cboUser.Column(2) Then
'Check if password needs to be reset
If Me.cboUser.Column(3) = True Then
DoCmd.OpenForm "frmPasswordChange", , , "[UserID] = " & Me.cboUser
End If
Me.cmdOpenMain.Enabled = True
Else
MsgBox "Password does not match, please re-enter!", vboOkOnly
Me.txtPassword = Null
Me.txtPassword.SetFocus
End If
End If
End Sub
There is a button created named cmdOpenMain on your login form, by default it is disabled and you can not press it, After giving the correct password, it will be enabled and the main form can be opened.
I have Ms-Access 2010 installed on my laptop so i coverted your db to 2010, however I am uploading your db back with the new changes.
Hope this help.