AllowLayoutView

continuation of previous post seems to be a character limit


designView=not designView

6. in the code which opens the form you would have something like

docmd.openform "myform",designView * -6

So your client wants to edit the form, closes it, clicks cmdDesignView then the button/whatever to reopen the form.

you might want to include another line of code after your openform to reset designView to false
 
Everyone logs in to the same FE to do some input data etc.
You have a fiduciary responsibility to your client or employer to protect his data to the best of your abilities. You are making a big mistake by not taking the expert advice to split the app. You should also pass on the warning to your client so that he knows the risk and is willing to accept it. If you leave things the way they are, change your phone number and disappear when you're done with the project. You do not want to hear from this client again because he will call crying about his lost data and you will be responsible for the mess because now you know how to do it responsibly.
 
the owner of the shop, opens and uses the forms like other staffs. But one day he decides he needs to change the size of a text box or some other minor changes in form design. He wants to be able to right click the form and select layout view and change the design of the form
so what happens when the business grows and the owner buys a second computer?

He knew I'm in collage and studying databases and asked me if I can find a way to allow him having access to layout view (only him).
just to be clear - you are not writing the app for him, the owner has written his own app and knows what he is doing, he's just asked you 'if there is a way' to switch to layout view whilst in normal view.

Suggest you provide him with a link to this thread
 
Here's another possibility to consider which was I think mentioned earlier in passing:
Let's say the form to be opened is called frmContactInfo and the function to check user permissions is called GetAccessLevel

Create a calling form with two buttons as shown below:
1614451336855.png


Now add the following code to the form:
Code:
Private Sub cmdOpenForm_Click()
    DoCmd.OpenForm "frmContactInfo", acNormal
End Sub

Private Sub cmdOpenFormLayout_Click()

    'only available to admin users
    DoCmd.OpenForm "frmContactInfo", acLayout
End Sub

Private Sub Form_Load()

    'modify the properties of form frmContactInfo according to permission level
    
    'iden form in design view & hidden
    DoCmd.OpenForm "frmContactInfo", acDesign, , , , acHidden

    Select Case GetAccessLevel
    
    Case 1 'standard user
        Forms!frmContactInfo.Form.AllowLayoutView = False
        Me.cmdOpenFormLayout.Enabled = False
    Case 2 'admin
        Forms!frmContactInfo.Form.AllowLayoutView = True
        Me.cmdOpenFormLayout.Enabled = True
    End Select
    
    'close hidden form & save changes
    DoCmd.Close acForm, "frmContactInfo", acSaveYes
    
End Sub

This automatically configures form frmContactInfo depending on user level. The user never sees the changes being done as that form is opened in design view and hidden, modified as appropriate, saved and closed again.

The button to open in layout view is disabled for standard users. If preferred the button could be hidden instead
 

Users who are viewing this thread

Back
Top Bottom