User level security using Vb code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajeevs
    New Member
    • Jun 2007
    • 171

    #1

    User level security using Vb code

    Hi
    I have a database created in Access. I have a table with different usernames and passwords. i want to create a log on form which will enable users to access the databse. How can i give permissions to different users for different level of access (restrict to open/view/edit etc )using visual basic code?
    The code should define the groups like owner, administrator, user like that
    Pls help

    Thank u
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by rajeevs
    Hi
    I have a database created in Access. I have a table with different usernames and passwords. i want to create a log on form which will enable users to access the databse. How can i give permissions to different users for different level of access (restrict to open/view/edit etc )using visual basic code?
    The code should define the groups like owner, administrator, user like that
    Pls help

    Thank u
    You are referring to a complex and confusing area when attempting to assign permissions on Objects using VBA, but this little code snippet will point you in the right direction. It will change the Permissions for the User 'Tom' on tblName to Insert and Retrieve data from this Table:[CODE=vb]' Ensure that the Microsoft Jet workgroup information file is available.
    DBEngine.System DB = "system.mdw "

    Dim MyDB As Database, docTemp As Document

    Set MyDB = CurrentDb()
    Set docTemp = MyDB.Containers ("Tables").Docu ments("tblName" )

    ' Change the permissions of Tom on the the Table tblName
    With docTemp
    .UserName = "Tom"
    .Permissions = dbSecRetrieveDa ta + dbSecInsertData
    If (.Permissions And dbSecInsertData ) = dbSecInsertData Then
    MsgBox .UserName & " can insert data." 'will display
    Else
    MsgBox .UserName & " can't insert data."
    End If
    End With

    MyDB.Close[/CODE]

    Comment

    Working...