Page 4 of 5 FirstFirst 12345 LastLast
Results 46 to 60 of 66
  1. #46
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771

    You have fields named "admin", "data", "reado"?

    Does your userID have admin and data and reado all set to True?

    If that is the case, then the last If Then condition will take effect.

    Should not be 3 separate If Then structures. Use If Then ElseIf

    I would use one field for permission level and assign user a value of "admin" or "data" or "reado".
    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.

  2. #47
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    It seems you are making this Access level (menu?) more complicated than it needs to be.

    I asked:
    1) How many Access levels do you have? Four levels of access
    So in the "tblAccessLevel" table, there is

    tblAccessLevelID tblAccessLevel
    1 Admin
    2 Dev
    3 Supervisor (Removed)
    4 DataEntry
    5 Reader (Read Only)

    But you have added (at least) 3 Boolean fields for access level when 1 would suffice.
    The default access level should be 5 - Read only. Modify the access level permission as required.


    Then I asked:
    3) How many Categories are there? There are 10 categories and each one has a unique form.
    So the "Category" ("OB01") determine which form opens.


    I modified your test dB:
    the tables "Catagory" & "tblAccessLevel"
    added a table "tblFormNames"
    added a form "frmAll", "CardiacForm" & "ObstetricsForm" (the last two are copies of "PaediatricForm" but with colors changed - for testing)
    & and changed code.

    So the idea is to open the correct form, then set the permissions.....

    Kinda crude yes, but functional???


    BTW, How is the Access level permissions for "Dev" different from "Admin"
    Last edited by ssanfu; 08-26-2014 at 11:07 AM.

  3. #48
    burrina's Avatar
    burrina is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    Dev should be for the Developer ONLY with unique abilities to edit security settings. Surprised this thread is still going!

  4. #49
    Sheba is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    239

    Exclamation

    hey Steve and June7, you guys are awesome. Thank you for the support you're giving me. I have adopted a number of approaches to resolve this issue. Yes, at first, I had a field and for each user, that field had "Admn","Dev","Data" or "Reader". It was simple but at some point, code was not applying the required permission levels so I researched some other methods (using more tables and stuff) and got meself entangled!

    Steve
    - In my program, successful login calls up switchboard to which ALL 10 forms are linked. Once login is successful, the user clicks on "his" form.
    If he clicks on one that is not his, he should get the "not authourised" message
    - I logged in to the database you uploaded but for every user login, it gives error 2102: The form name 'ObstetricsForm' is misspelled or refers to a form that doesn't This line of code is highlighted in yellow colour: DoCmd.OpenForm FrmName, , , , , , AccLv1


  5. #50
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Why should user have to click on 'his' form? Why doesn't code just open the appropriate form? Why do users have different forms? Are these forms all for different purposes - different data?
    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. #51
    Sheba is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    239
    The switchboard was the way to go because the application will cater to more than 'these' users. Switchboard has links to another switchboard (incomplete) that will be used for analyses by another set of users). There are different forms because they convey different information. Each one represents a unique category

  7. #52
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Sheba,
    Oop, I was going too fast, trying too many things, making changes on-the-fly and forgot to delete the "_M" from the form names in the "Category" table.
    I fixed it and uploaded a new test dB.

    It is hard to give good advice when you don't have the full story. I *was* curious why 10 forms..... but it is the full story thing..

    I really think you need to separate the Access level code from the form permission code.


    Anyway, maybe my menu attempt will give give you some ideas......

  8. #53
    Sheba is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    239

    Exclamation

    Question: I took the code SELECT code and encased it in an IF statement (like below). but I'm getting error 94: Invalid use of Null
    The 'debug' button on the dialogue box is also greyed out

    If DLookup("CategoryID", "tblUser", "strPassword='" & Forms!frmLogin.txtPassword & "'") = 122 Then
    SELECT Case
    ...
    ...
    End Select
    Else
    MsgBox "You are not authorized to view this form"
    Cancel = True
    DoCmd.Close acForm, Me.Name
    Forms!frmLogin.Visible = True
    End If

  9. #54
    Sheba is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    239
    okay thanks Steve, just seen your update. Just wondering how to still adopt your code to include the switchboard...

  10. #55
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You are missing part of the command.

    SELECT CASE testexpression


    Here is how I would write it:
    (change IF() control structure to SELECT CASE structure)
    Code:
    Dim CatID as long     ' << at the top of the procedure
    
    .
    . code
    .
    
    CatID =  DLookup("CategoryID", "tblUser", "strPassword='" & Forms!frmLogin.txtPassword & "'") 
    ' CatID now contains 122
     
     SELECT Case CatID
       Case 1
         ...
       Case 122
        ...      'Code goes here for "CategoryID" = 122
    
       Case Else
         MsgBox "You are not authorized to view this form"
         Cancel = True
         DoCmd.Close acForm, Me.Name
         Forms!frmLogin.Visible = True
     End Select




    Just wondering how to still adopt your code to include the switchboard
    Not trying to redesign your dB .... Hopefully providing ideas...
    You need to do what you are comfortable with.

  11. #56
    Sheba is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    239
    brilliant! Steve I'm indebted to you Thank you but just for clarity sake. If I'm going to use catID 122 in the Select Case statement, then I'll have to refer to the other 9 IDs in the Category table wouldn't I? and then repeat the whole code for each form of the 10 forms.
    hm...(just thinking out loud here) looks kinda crude? well I'll try that first and hope it works

  12. #57
    Sheba is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    239
    thinking deeper... The Case should refer to the different levels of access (i.e. Admn, Dev, Supvr,Data, Reader) shouldn't it? I mean besides the DataEntrant, the Admin or Develop could want access to the form. I'm thinking...

    CatID = DLookup("CategoryID", "tblUser", "strPassword='" & Forms!frmLogin.txtPassword & "'")
    ' CatID now contains 122

    SELECT Case CatID
    Case 111
    .... 'Code goes here for "Admn"
    ... 'Code goes here for "Dev"

    Case 122
    ... 'Code goes here for "Data"
    ... 'Code goes here for "Reader"

    Case Else
    MsgBox "You are not authorized to view this form"
    Cancel = True
    DoCmd.Close acForm, Me.Name
    Forms!frmLogin.Visible = True
    End Select

  13. #58
    Sheba is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    239
    thinking deeper... The Case should refer to the different levels of access (i.e. Admn, Dev, Supvr,Data, Reader) shouldn't it? I mean besides the DataEntrant, the Admin or Develop could want access to the form. I'm thinking...

    CatID = DLookup("CategoryID", "tblUser", "strPassword='" & Forms!frmLogin.txtPassword & "'")
    ' CatID now contains 122

    SELECT Case CatID
    Case 111
    .... 'Code goes here for "Admn"
    ... 'Code goes here for "Dev"
    Case 122
    ... 'Code goes here for "Data"
    ... 'Code goes here for "Reader"

    Case Else
    MsgBox "You are not authorized to view this form"
    Cancel = True
    DoCmd.Close acForm, Me.Name
    Forms!frmLogin.Visible = True
    End Select

  14. #59
    Sheba is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    239
    ah yai yai! how do I differentiate between Data and Reader (admn and dev) inside the Case statement

  15. #60
    Sheba is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    239
    Below is the code I used but logged in as a Data Entrant, I can still delete a record. Sigh! I feel like I've run a marathon and still come to the same position. I guess I'll just have to Set the darn Form property AllowDeletions to No

    dim UserLevel blah blah
    dim CatID bla blah

    UserLevel
    = DLookup("AccessLevelID", "tblUser", "strPassword='" & Forms!frmLogin.txtPassword & "'")
    CatID
    = DLookup("CategoryID", "tblUser", "strPassword='" & Forms!frmLogin.txtPassword & "'")

    SELECT Case CatID
    Case 111
    With Me
    If userlevel = 1 then
    .... 'Code goes here for "Admn"
    Elseif userlevel = 2
    ... 'Code goes here for "Dev"
    End If
    End with
    Case 122
    With Me
    If userlevel = 4 then
    ... 'Code goes here for "Data"
    Elseif userlevel = 5
    ... 'Code goes here for "Reader"
    End If
    End with

    Case Else
    MsgBox "You are not authorized to view this form"
    Cancel = True
    DoCmd.Close acForm, Me.Name
    Forms!frmLogin.Visible = True
    End Select

Page 4 of 5 FirstFirst 12345 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 10-23-2013, 08:11 AM
  2. Replies: 5
    Last Post: 01-16-2013, 03:48 PM
  3. Multiple forms or embedded sub-forms
    By Juicejam in forum Forms
    Replies: 2
    Last Post: 08-23-2011, 07:31 AM
  4. Replies: 1
    Last Post: 01-04-2011, 05:04 AM
  5. Replies: 4
    Last Post: 04-01-2009, 08:49 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