Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22
  1. #16
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791

    it might be the dlookup function to carry out this particular command does not work in Access 2016
    If you mean me, then that's not what I meant to imply. I meant that sometimes improper syntax will run or compile in earlier versions but will fail in later ones. In those cases, it's the syntax of the function call that is the problem, not the function itself. As for me, I still have no idea where or what CurrentUser is in your code.
    Last edited by Micron; 03-14-2019 at 09:03 PM. Reason: clarification

  2. #17
    cariboy is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    10
    i have attached a shell copy of the database. use this login information username: jbrowne password: password
    Attached Files Attached Files

  3. #18
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Every module should have Option Explicit in header. This can be set to occur automatically when module is created. On the VBA editor menu: Tools > Options > Editor > Require variable declaration

    The username is not filled in when user is required to change password. Subsequent logins work.

    Form tblUser AllowAdditions property should be set to No. Password EnterKeyBehavior should be set to Default. Why would you allow new line in a password string? Also, only Password textbox should be editable. The other textboxes should be disabled.

    On Login form change TabOrder of controls so textbox gets focus when form opens. I would not use Popup or Modal. SetFocus for textboxes is not working and haven't figured out why.

    Suggest naming Command1 something more descriptive.

    Consider:

    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub Command1_Click()
    Dim ID As Integer
    Dim UserName As String
    Dim AccessLevel As Integer
    
    If IsNull(Me.TxtLoginID) Then
        MsgBox "Please enter LoginID", vbInformation, "LoginID Required"
        Me.TxtLoginID.SetFocus
    ElseIf IsNull(Me.TxtPassword) Then
        MsgBox "Please enter Password", vbInformation, "Password Required"
        Me.TxtPassword.SetFocus
    ElseIf IsNull(DLookup("UserLogin", "tblUser", "UserLogin ='" & Me.TxtLoginID & "'  And password = '" & Me.TxtPassword & "'")) Then
        MsgBox "Incorrect LoginID or Password"
    Else
        ID = DLookup("UserID", "tblUser", "UserLogin = '" & Me.TxtLoginID.Value & "'")
        UserName = DLookup("[UserName]", "tblUser", "[UserLogin] = '" & Me.TxtLoginID & "'")
        AccessLevel = DLookup("UserSecurity", "tblUser", "UserLogin = '" & Me.TxtLoginID & "'")
        If Me.TxtPassword = "password" Then
            MsgBox "Please Change Password", vbInformation, "New Password Required"
            DoCmd.OpenForm "tblUser", , , "[UserID] =" & ID, , acDialog
        End If
        DoCmd.OpenForm "MAIN SCREEN"
        Call Security(AccessLevel)
        Forms![MAIN SCREEN]![TxtUser] = UserName
        Forms![MAIN SCREEN]![txtsecurity] = AccessLevel
        DoCmd.Close acForm, "Login", acSaveNo
    End If
    End Sub
    
    Sub Security(UserSecurity As Integer)
    Select Case UserSecurity
        Case 1  'Admin
        
        Case 2  'User
            'me.AllowEdits = true
            MsgBox "Your User Level Is 'User'"
            Forms![MAIN SCREEN]!CmdAdmin.Enabled = False
    End Select
    End Sub
    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub CmdSaveNPW_Click()
    DoCmd.Close
    End Sub
    
    Private Sub Password_BeforeUpdate(Cancel As Integer)
    If Me.Password = "password" Or Me.Password.OldValue = Me.Password Then
        MsgBox "Invalid password."
        Cancel = True
        Me.Password = Null
    End If
    End Sub
    Last edited by June7; 03-15-2019 at 08:27 PM.
    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.

  4. #19
    cariboy is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    10
    thanks for your suggestions and i will look into them, were you able to solve my initial issue....Making that button that says admin on the main screen available or not based on the user login and making the user's name appear on "Main Screen"? is the code posted after your last reply the updated code to make this work, just a quick look at it and it looks a little different from the one i post, i could be wrong

  5. #20
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Yes, the code is a bit different. Wait, I was so focused on the Username issue, forgot to look at the Admin button.

    I just noticed the code in the MAIN SCREEN Load event which is attempting to do what is also done in the Login form - why? Which procedure do you want? You never posted the Load code nor even mentioned it. The textbox does not have value when the Load event runs so this negates whatever was done by the login form code.

    If you want code in MAIN SCREEN to manage itself (which is my preference), then suggest passing values via OpenArgs argument of OpenForm and use Open event to set controls.
    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.

  6. #21
    cariboy is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    10
    June7 thanks for adjusting the code...I'm still to update my database with what you suggest...once i do i will let you know how that worked. Sorry I really thought i did mention that restriction of the "Admin button". To be honest i'm at a total lost as to the other things you said in your last post. The main screen should do this; after login in, the "Main Screen" load, with the user name at the top right hand (is your new code doing this?) and the "Admin Button" enable or disable based on the user's security...is this already being done at the login screen level? what do you mean by "If you want code in MAIN SCREEN to manage itself (which is my preference), then suggest passing values via OpenArgs argument of OpenForm and use Open event to set controls." I'm not too verse in coding

  7. #22
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Exactly what do you not understand - OpenArgs? Two procedures are setting controls of the MAIN SCREEN form and conflicting. Eliminate one.
    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.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-27-2016, 07:36 PM
  2. Replies: 13
    Last Post: 10-02-2014, 09:29 AM
  3. Display query results on user form
    By Ganesh7299 in forum Access
    Replies: 3
    Last Post: 12-28-2013, 06:19 AM
  4. Replies: 6
    Last Post: 02-21-2013, 10:52 AM
  5. Replies: 7
    Last Post: 02-13-2013, 12:55 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