AllowLayoutView (1 Viewer)

Sun_Force

Active member
Local time
Today, 21:23
Joined
Aug 29, 2020
Messages
396
According to documents AllowLayoutView is a Read/Write property.


This is a part of a test:
SQL:
Public Sub PrepareForm(frm As Access.Form)
    ......
    .AllowLayoutView = IsAdmin
    ......
End Sub

IsAdmin is a function to check if current user is a member of Admin group.
Running this code, I receive the following error.
To Set this property, open the form or report in Design view

  1. If it's said AllowLayoutView can be set in vba, why I receive this error. It doesn't make sense to open a form in design view, change a property, save it and open it again in VBA.
  2. Is it possible to allow some users being able to use layout view and others not dinamically?


thank you.

-
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 08:23
Joined
May 21, 2018
Messages
8,553
  1. If it's said AllowLayoutView can be set in vba, why I receive this error. It doesn't make sense to open a form in design view, change a property, save it and open it again in VBA.
There are a lot of things that are read / write that cannot be set without being in design view. You may not like it, but that is how it is. Opening a form can be done if this is not an accde. So you could open in design view and hidden. Change the property and Open. Most people are building apps would have this locked down a lot more than that (custom menus, toolbars) that getting to layout view would not be possible except admins.

  1. Is it possible to allow some users being able to use layout view and others not dinamically?

You could open, change, and close (all hidden) and open. This would happen seamlessly. It can be done, but I would never open in design view at runtime. Like I said you can provide your own ribbons and shortcut menus. I rarely show any ribbon except to admin
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 05:23
Joined
Aug 30, 2003
Messages
36,127
The form has to be open one way or the other to change a property. Perhaps set this in the open or load event?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:23
Joined
May 7, 2009
Messages
19,247
don't take the word of everything that is written.
test to prove or break it.
post comment on "errata" section of that site.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 13:23
Joined
Feb 19, 2013
Messages
16,628
agree with other comments about a risky path to tread but you can open the form in layout view from docmd.openform


so set your view preference there, as part of opening the form
 

Sun_Force

Active member
Local time
Today, 21:23
Joined
Aug 29, 2020
Messages
396
The form has to be open one way or the other to change a property. Perhaps set this in the open or load event?
I should have explained that I'm running the function from on-open event. Sorry for not being clear enough.
 

Sun_Force

Active member
Local time
Today, 21:23
Joined
Aug 29, 2020
Messages
396
agree with other comments about a risky path
I'm sending this database to someone else. The owner of the shop needs to be able to access to layout view, but not his staff.
I thought I can set this property in open view of the form according to their rights.

I'm open to any other idea that may be helpful in this situation.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 05:23
Joined
Aug 30, 2003
Messages
36,127
I should have explained that I'm running the function from on-open event. Sorry for not being clear enough.

My apologies, it appears the form has to be in design view. I initially thought you were doing this with the form closed and assumed it could be done while open. A brief test shows it has to be in design view, which others have addressed.
 

Sun_Force

Active member
Local time
Today, 21:23
Joined
Aug 29, 2020
Messages
396
You could open, change, and close (all hidden) and open. This would happen seamlessly. It can be done, but I would never open in design view at runtime. Like I said you can provide your own ribbons and shortcut menus. I rarely show any ribbon except to admin
Actually I had thought about this, but preferred to use it when any other solution fails.
Thanks for the advice.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 08:23
Joined
May 21, 2018
Messages
8,553
I think you could do as @CJ_London states. You probably have a switchboard with different permissions for different users. You can have a button to open in layout view even though the form is defaulted to not allow.
 

Sun_Force

Active member
Local time
Today, 21:23
Joined
Aug 29, 2020
Messages
396
I think you could do as @CJ_London states. You probably have a switchboard with different permissions for different users. You can have a button to open in layout view even though the form is defaulted to not allow.
I'm sorry but I fail to understand how it works.
Let me explain the whole story.

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.
For sure I can tell him to open the database unlocked, search for the form, right click and select design or layout view, but he wants the easy way.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:23
Joined
May 7, 2009
Messages
19,247
I'm sending this database to someone else. The owner of the shop needs to be able to access to layout view, but not his staff.
i wouldn't do that. it is highly prone to modification.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:23
Joined
May 7, 2009
Messages
19,247
But one day he decides he need to change the size of a text box or some other minor changes of form design.
you can't give him and accde for sure.
you need to create a "special" shortcut menu that only he can access the Layout view.
 

Sun_Force

Active member
Local time
Today, 21:23
Joined
Aug 29, 2020
Messages
396
you can't give him and accde for sure.
you need to create a "special" shortcut menu that only he can access the Layout view.
The file is accdb.
I'm googling shortcut menu. But haven't find anything clear yet.
Any link you can share?

thanks.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:23
Joined
Feb 19, 2002
Messages
43,331
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.
For sure I can tell him to open the database unlocked, search for the form, right click and select design or layout view, but he wants the easy way.

If you have set up the app correctly, the "owner" will be opening a copy of the FE that should NOT be changed. It will be overwritten the next time he reopens the app.

The owner, if he wants to be able to make changes himself, MUST learn to use the discipline of a programmer. That means, he copies the Master to his local drive, makes the FE changes he wants. Compiles and tests. When he is happy with the changes, he renames the current master and uploads the new master.

Personally, my position is, if the client wants to make changes himself, don't call me when it breaks. If he wants me to take his calls and fix things, I need to know that no one bur myself is making changes to anything.
 

Sun_Force

Active member
Local time
Today, 21:23
Joined
Aug 29, 2020
Messages
396
@Pat Hartman
I know all the advice I received here from you or others are the best way to go.
But it's a small shop with several staff and only one PC. He has written the database himself. Everyone logs in to the same FE to do some input data etc.

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).
I suggested to test AllowLayoutView, but it didn't work. So I asked the question here to see what experienced users do in this situation.
Apparently as @MajP pointed out, it seems things are not that simple. Though the document says it's a read/write parameter, but the form needs to be in design view and it makes no sense to open a form in vba, change a property and save it and open it again every time a user opens a form.
 

isladogs

MVP / VIP
Local time
Today, 13:23
Joined
Jan 14, 2017
Messages
18,246
The way to allow different permissions is to assign user levels to each user who will then need to login with user name and password.
Standard users will have limited permissions. The admin user will be able to do more.
That is a standard approach used to manage many databases.

However, the previous comments/warnings still apply.
 

Sun_Force

Active member
Local time
Today, 21:23
Joined
Aug 29, 2020
Messages
396
That is a standard approach used to manage many databases.
That system is inplace and works great. Each user logs in and has his/her own rights.
My question was how to allow a user access layout view and prevent others to access it. (with only one FE)
 

CJ_London

Super Moderator
Staff member
Local time
Today, 13:23
Joined
Feb 19, 2013
Messages
16,628
As advised.

1. You cannot change the view whilst in 'normal' view' so this cannot be done. End of

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.

2. you can open the form in layout view, so if the owner decides he needs to edit the form, he needs to close it, and reopen it in layout view. He does not need to go into the full design of the app

To do this, you could

1. have a global boolean variable or tempvar called say 'designView'

2. on opening the app, this is set to false

3. somewhere in your app, probably a navigation or menu form you could have a button called say cmdDesignView, perhaps with some conditional formatting to show the current 'state' - i.e. 'normal' or 'design'

4. this would only be visible if the user is 'admin'/whatever
 

Users who are viewing this thread

Top Bottom