Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Welcome to the skill header Forums. You can ask questions, get help, or help other members out. Join our Forum for free.

Active Profile User...
 
Notifications
Clear all

[Solved] Active Profile User Restrictions

7 Posts
2 Users
3 Reactions
160 Views
Posts: 8
Topic starter
(@quadcrazi)
Active Member
Joined: 4 months ago

I'm currently on video 17 and have never gotten the user restrictions to work properly based on active profile ID.

When I login using 'User1' for the first time, none of the tabs are restricted. If I login a second time, the tabs are restricted as they should be. But, if I login to 'Admin' next the same tabs are restricted. However, if I login to 'Admin' for the second time, the tabs are working as they should. The restrictions always work correctly the second time you login but never the first time if you are switching profiles. Please help!

I have double checked 'prfID' in User table and double checked 'prfID' and true/false (-1 and 0) in Profile table. I also double checked coding compared to my source code file just to make sure.

6 Replies
Posts: 8
Topic starter
(@quadcrazi)
Active Member
Joined: 4 months ago

Note: The same thing happens on the Skill Header database.

Reply
FStetson
Posts: 55
(@fstetson)
Trusted Member
Joined: 6 months ago

Interesting!  Will check it out.

Reply
FStetson
Posts: 55
(@fstetson)
Trusted Member
Joined: 6 months ago

I was able to duplicate the issue using V17 source file.  However, I do not see the issue in my Db.  I found the problem....the Main dashboard is opening before the profile is being set by the login form.  Change your VBA code for your login command button as follows: (note I moved the DoCmd.OpenForm "MainDashboard" to come after aprofile is set.  This works on V17 source file now.  Let us know if you have any other problems.

Private Sub cmdLogin_Click()
'First check the null textboxes and return a msg
If IsNull(Me.txtUsername) = True Or IsNull(Me.txtPassword) = True Then
    MsgBox "Please enter Username and Password...", vbExclamation, "|Username or Password Blank|"
    Exit Sub
        Else
            'Find the record in user table based on both username and password
            ufound = DCount("uUsername", "tbl_user", "uUsername = '" & Me.txtUsername & "' and uPassword = '" & Me.txtPassword & "' and uStatus = 'Active'")

            'Record not found
            If ufound = 0 Then
                Me.LblNotFound.Visible = True
                Exit Sub
                    'Record found
                    Else
                        'user ID (It must be defined as Public Variable)
                        uI = DLookup("uID", "tbl_user", "uUsername= '" & Me.txtUsername & "'")
                        uN = Me.txtUsername
                        '///logs
                        Set ulog = CurrentDb.OpenRecordset("tbl_logs", dbOpenDynaset, dbSeeChanges)
                        With ulog
                            .AddNew
                            .Fields("logDate") = Date
                            .Fields("logTime") = Now()
                            .Fields("logActivity") = "Logged in"
                            .Fields("logDetail") = Me.txtUsername & " logged in"
                            .Fields("uID") = uI
                            .Update
                        End With
                        Set ulog = Nothing
                            
                      
                        'Active profile ID (Which declared as public variable)
                        aprofile = DLookup("prfID", "tbl_user", "uUsername = '" & Me.txtUsername & "'")
                        
                        'Open Main Dashboard form
                        DoCmd.OpenForm "MainDashboard"
                        
                        'Update the Username textbox in the Main form
                        Forms!MainDashboard.txtActiveUser.Value = Me.txtUsername
                        

                        'Update the profile ID in the main form
                        Forms!MainDashboard.txtActiveProfile.Value = aprofile
                        
                        'Close the login form
                        DoCmd.Close acForm, "LoginForm"
            End If
End If
End Sub
Reply
FStetson
Posts: 55
(@fstetson)
Trusted Member
Joined: 6 months ago

BTW, that is a good catch!  I am sure others will benefit as well.

Reply
1 Reply
(@quadcrazi)
Joined: 4 months ago

Active Member
Posts: 8

@fstetson Fixed! Thank you! I wouldn't have guessed it was such a simple fix!

Reply
Page 1 / 2
Share: