Results 1 to 6 of 6
  1. #1
    zaaimanm is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    3

    Post HELP>Access 2010 User Login Form Code.

    Hi,
    I created a user login form for my database.
    Please see code below.



    The below code works fine, howver what i now need to add is a way to only bring up the relative data for the user logging in.

    In tbleSuper i have Username, Password and Department.
    When the users logs in I need it to only bring up the data for their department. I have already set up the relationship if necessary


    Private Sub Command7_Click()
    If IsNull(Me.Combo5) Or Me.Combo5 = "" Then
    MsgBox "You must enter a UserName.", vbOKOnly, "Required Data"
    Exit Sub
    End If
    If IsNull(Me.Text2) Or Me.Text2 = "" Then
    MsgBox "You must enter a Password.", vbOKOnly, "Requierd data"
    Me.Text2.SetFocus
    Exit Sub
    End If
    If Me.Text2.Value = DLookup("strPassword", "tblSuper", "[ID]=" & Me.Combo5.Value) Then
    ID = Me.Combo5.Value
    DoCmd.Close acForm, "Form1", acSaveNo
    DoCmd.OpenForm "tblUsers"
    Else
    MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
    Me.Text2.SetFocus
    End If
    intLogonAttempts = intLogonAttempts + 1
    If intLogonAttempts > 3 Then
    MsgBox "You do not have access to this database.Please contact admin.", vbCritical, "Restricted Access!"
    Application.Quit
    End If
    End Sub


    Thank you

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    You will have to include filter criteria in each form/report recordsource that restricts records to the user's id or department/division, whatever.

    My method is to set a textbox on form that never closes (a main menu) to the criteria value. Reference this textbox as filter parameter in relevent queries and recordsources.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    zaaimanm is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    3

    Thanks

    Quote Originally Posted by June7 View Post
    You will have to include filter criteria in each form/report recordsource that restricts records to the user's id or department/division, whatever.

    My method is to set a textbox on form that never closes (a main menu) to the criteria value. Reference this textbox as filter parameter in relevent queries and recordsources.
    I will try this,

  4. #4
    troggernaught is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    5
    You can use TempVars to store the department.

    Example: TempVars!dept = DLookup("strDepartment"...

    and then use TempVars!dept in your queries or recordsources...

    Example: SELECT * FROM mytable WHERE department=TempVars!dept

  5. #5
    zaaimanm is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    3

    Smile Thanks

    Thanks All, got it sorted.

  6. #6
    mcsrta is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    1
    Zaaimanm
    I am also a novice at this and looking for the same type of code to filter in only the records that match the user department or ID after they have login correctly. Will you please email me the code that you got to work. My email in brewtonm@bcs7.net.

    Thank You.

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

Similar Threads

  1. User permissions - access 2010
    By Outlook in forum Security
    Replies: 3
    Last Post: 12-03-2012, 08:19 AM
  2. Replies: 3
    Last Post: 09-22-2011, 03:35 PM
  3. Login form code not working
    By dharmacloud in forum Forms
    Replies: 11
    Last Post: 08-22-2011, 03:08 PM
  4. Login ID Code for Access 2007 not working
    By amangupts in forum Programming
    Replies: 25
    Last Post: 07-07-2011, 01:28 PM
  5. Login Form Code
    By paddon in forum Programming
    Replies: 4
    Last Post: 04-08-2011, 06:48 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