Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
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.
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.
Note: The same thing happens on the Skill Header database.
Interesting! Will check it out.
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
BTW, that is a good catch! I am sure others will benefit as well.