Results 1 to 4 of 4
  1. #1
    foxtet is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    23

    Arrow Enable command buttons based on login


    I’m developing a small database to track patient’s records. I want particular group of people to access data only they are authorized.

    To do this I have created a login form and users can log on to the database through login. In the main window I have a list box and command buttons. So what I need is that to allow users to access command buttons based on their access level defined in user table. Can anyone explain me how may I build a solution for this?? Any help is appreciated..

  2. #2
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    What you have done so far, are you looking for the users in a table and is your form asking for their username and password????

    you need to have a users table with their passwords and a login form with two textboxes: a username and password.
    call the procedure on after update event of the username to get your authorized username and password: (DLOOKUP) will give you your usernames and passwords.
    After matching your username with the correct password, your button should be enabled to true (by default it should be enabled to false)

    pseudo code:

    Private sub Afterupdate of userNameTxt()
    DLOOUP(yourfield,yourtable,criteria)
    get the username and password
    ......
    if match
    button enabled = ture
    ....
    else
    button enabled= false
    end if
    ....
    your other procedures
    ....
    end sub

  3. #3
    foxtet is offline Novice
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    23
    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

  4. #4
    khalid's Avatar
    khalid is offline MS-Access Developer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2010
    Location
    Kuwait
    Posts
    244
    Quote Originally Posted by foxtet View Post
    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.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Command Buttons
    By BLD21 in forum Access
    Replies: 2
    Last Post: 05-10-2011, 06:27 AM
  2. Command Buttons
    By Rosier75 in forum Access
    Replies: 3
    Last Post: 03-09-2011, 11:59 AM
  3. command buttons
    By nashr1928 in forum Forms
    Replies: 23
    Last Post: 10-15-2010, 04:09 PM
  4. Command buttons
    By maintt in forum Forms
    Replies: 3
    Last Post: 08-03-2010, 09:52 AM
  5. Moving Command Buttons
    By Pete Cope in forum Forms
    Replies: 0
    Last Post: 03-23-2010, 03:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums