Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 16th, 2005, 03:43 PM
Authorized User
 
Join Date: Dec 2004
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: forms lock down problem on Access97

Hi All,
   We tried to add some security features into the database. We created a module named IsInGroup as follows:
    Public Function IsInGroup(UsrName As String, GrpName As String) As Boolean
'Determines whether UsrName is a member of GrpName

    Dim grp As Group
    Dim IIG As Boolean
    Dim usr As User

    IIG = False

    For Each usr In DBEngine.Workspaces(0).Users
        If usr.name = UsrName Then GoTo FoundUser
    Next

FoundUser:
    For Each grp In usr.Groups
        If grp.name = GrpName Then IIG = True
    Next

IIG_Exit:
    IsInGroup = IIG

End Function

Then in the on current event of the form, we add a event procedure as follows:
   If (IsNull(Me.creator) Or CurrentUser( )= Me.creator Or IsInGroup(CurrentUser(), "test_admin") Then
    Me.AllowAddition = True
    Me.AllowDeletions = True
    Me.AllowEdits = True
   Else
     Me.AllowDeletions = False
     Me.AllowEdits = False
   EndIF
Note: "creator" is a field in the table.

Those codes worked on the ACCESS 2K, but it didn't work for ACCESS97. I am wondering can anyone give me any suggestions how can I add this feature to ACCESS97. Thanks!


flyfish
__________________
flyfish
 
Old March 16th, 2005, 04:31 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Flyfish,

I don't know if this will work or not.
Instead of using the on current, on the command button that opens the form, put this in:
stdocname = formname

   If (IsNull(Me.creator) Or CurrentUser( )= Me.creator Or IsInGroup(CurrentUser(), "test_admin") Then
    docmd.openform stdocname,acnormal,,acformadd
   else
    docmd.openform stdocname,acnormal,,acformedit
   end if

This way, when the user opens the form, all they can do is add new records. If you have a button on your form to delete the current record, then add this when they don't have authorization to delete:
   me.deletecommandbutton.enabled = false
note: add it after the docmd.openform statement.

Like I say, I don't know if this will work for you. I think(oxymoron!) that it will work in both 97 and up.

Let me know!

Kevin




dartcoach
 
Old March 17th, 2005, 09:00 PM
Authorized User
 
Join Date: Dec 2004
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi dartcoach,
   I tried the code you posted for me yesterday. I got the complie error saying:
   "Expected variable or procedure, not module." Do you know why?
    What does "oxymoron" mean?
    Thanks for any suggestions!

flyfish
 
Old March 17th, 2005, 09:09 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Ya Flyfish!

Oxymoron - contradiction in terms, you know - military intelligence, me and thinking.

Are you trying to open this form from another form?
How is the form getting opened?

Kevin

dartcoach





Similar Threads
Thread Thread Starter Forum Replies Last Post
Access97 local forms in Access 2000/2002 vance696 Access 2 October 14th, 2005 10:26 AM
continue topic: form lock down problem flyfish Access 6 March 30th, 2005 11:31 AM
Re: forms lock down problem on Access97 flyfish Access 0 March 16th, 2005 03:34 PM
lock form problem flyfish Access 2 March 2nd, 2005 01:07 PM
problem to "on caps lock progametically Abhinav_jain_mca General .NET 3 August 5th, 2004 03:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.