Solved

How do I set edit permissions on a form without opening it?

Posted on 2011-09-23
5
263 Views
Last Modified: 2012-08-13
Hi all,

I am trying to implement a user-level type edit restrictions on a (test) form.  I have got it working but only when the form is already open. If it is closed when I log in, it can't find the form to set the properties.

Any ideas as to a better way of doing it?

Thanks in advance...
0
Comment
Question by:JohnSaint
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 57
ID: 36587843
<<I am trying to implement a user-level type edit restrictions on a (test) form. >>

  in what way?

<<Any ideas as to a better way of doing it? >>

  Do it in the forms OnOpen event, which is cancelable.  However you will need to do a Me.Repaint to ensure that all the controls are created if your controlling security on those as well. Normally, they are not available until the OnLoad event, but that event is not cancelable.

Jim.

0
 

Author Comment

by:JohnSaint
ID: 36587996
Hi Jim,

At the moment I am just doing it through a simple log-on form. That side of things I will deveop later but if you have any great ideas on that front then I'm all ears. Will set you with a separate question if that's what it takes.

I am not planning to apply security to indiviual controls. I'll just set the allowedits, additions etc to false if they are a 'View only' user. I was planning on doing a blanket sweep across all the forms setting the permissions but I guess doing it if and when the form opens is a better way. I could just set up a public proc (or whatever) and send the form name to it on open.

Whatever level my users are they will have access to all forms. Some will have full edit permision, some will only be able to view so I should never have to lock a user out of the form completely.

Am i heading in the right direction?
0
 

Author Comment

by:JohnSaint
ID: 36588042
And this doesn't work...

    Fname = "FrmAllAccess"
   
    Forms!Fname.AllowAdditions = True

How do I pass a form name in this case?
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 36588292
<<I'll just set the allowedits, additions etc to false if they are a 'View only' user. I was planning on doing a blanket sweep across all the forms setting the permissions but I guess doing it if and when the form opens is a better way.>>

 You'll be better off to do it when the form opens.  There are any number of ways to structure that.  I have a tendency to try and keep things centralized, so I would do one routine:

Sub SetFormPermissions(frm as Form)

   If <some check> = True then
     frm.AllowAdditions = True
     frm.AllowEdits = True
     frm.AllowDeletions = True
Else
     frm.AllowAdditions = False
     frm.AllowEdits = False
     frm.AllowDeletions = False
End If

End Sub

  Call would be:

   SetFormPermissions([Form])

  you might also want to pass as a string:


Sub SetFormPermissions(strFormName as String)

   If <some check> = True then
     Forms(strFormName).AllowAdditions = True
     Forms(strFormName).AllowEdits = True
     Forms(strFormName).AllowDeletions = True
Else
     Forms(strFormName).AllowAdditions = False
     Forms(strFormName).AllowEdits = False
     Forms(strFormName).AllowDeletions = False
End If

  Call would be:

   SetFormPermissions("myForm")

 it could also be done like this:

Sub SetFormPermissions(strFormName as String)
  Dim frm as Form

  Set frm = Forms(strFormName)

   If <some check> = True then
     frm.AllowAdditions = True
     frm.AllowEdits = True
     frm.AllowDeletions = True
Else
     frm.AllowAdditions = False
     frm.AllowEdits = False
     frm.AllowDeletions = False
End If

   set frm = nothing

End Sub

Or a little more concise:

Sub SetFormPermissions(strFormName as String)
  Dim frm as Form

  Set frm = Forms(strFormName)

  With frm

   If <some check> = True then
     .AllowAdditions = True
     .AllowEdits = True
     .AllowDeletions = True
Else
     .AllowAdditions = False
     .AllowEdits = False
     .AllowDeletions = False
End If

  End With

   set frm = nothing

End Sub


   
0
 

Author Closing Comment

by:JohnSaint
ID: 36598791
Cheers Fella. Great work...
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question