josephbupe
Registered User.
- Local time
- Today, 19:54
- Joined
- Jan 31, 2008
- Messages
- 247
Hi,
I have a user login code am using for users to login and only access their records in a subform according to their user ID and access level (user or admin). On the main form I have a user name field, the password field and two other fields: one to hold userID and the other to hold access level.
I also want if the person logged in has "Admin" access level the subform should return records from all users. For now what is happening is that even when I assign myself with "Admin" access level, the subform is not returning all records from other users, but my own records only. The original demo where I found the code worked well but I cannot find it and I am totally lost on this.
I hope someone here will no what I am driving at and subsequently help me.
Here is the code I have so far:
I have a user login code am using for users to login and only access their records in a subform according to their user ID and access level (user or admin). On the main form I have a user name field, the password field and two other fields: one to hold userID and the other to hold access level.
I also want if the person logged in has "Admin" access level the subform should return records from all users. For now what is happening is that even when I assign myself with "Admin" access level, the subform is not returning all records from other users, but my own records only. The original demo where I found the code worked well but I cannot find it and I am totally lost on this.
I hope someone here will no what I am driving at and subsequently help me.
Here is the code I have so far:
Code:
Private Sub cmdLogin_Click()
Me.Hold_User_ID = Nz(DLookup("User_ID", "T_Users", "Username='" & Me.UserName & "' and pword='" & Me.PWD & "'"), -1)
' check to see if we have a good login
If Me.Hold_User_ID = -1 Then
MsgBox "Invalid username or password."
Else
' load the users access level into the holder form field
Me.hold_level = DLookup("access_level", "T_Users", "Username='" & Me.UserName & "' and pword='" & Me.PWD & "'")
Forms.F_FileCases!F_Cases.Visible = True
Me.cmdNewCase.Visible = True
Me.Frame2.Visible = True
End If
' need to requery the subform
Me!F_Cases.Requery
' note that inorder to refer to the F_ToDos_view form directly using Form_
' the forms Has Module property must be set to Yes
If Me.hold_level.Value = "Admin" Then
Me.cmdUsers.Visible = True
Else
Me.cmdUsers.Visible = False
End If
End Sub