Solved

How to set the AllowDesignChanges property

Posted on 2010-09-16
34
495 Views
Last Modified: 2013-11-28
I assume that to set AllowDesignChanges=False for every form in a database via code, you have to open  each form in design view.

Is there a faster way?
0
Comment
Question by:Milewskp
  • 14
  • 10
  • 5
  • +1
34 Comments
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 100 total points
ID: 33697650
dunno unless you coded it yourself, maybe something like this


    Dim i As Integer
    Dim sName As String
   
    'Go thru list
    For i = 0 To CurrentDb.Containers("Forms").Documents.count - 1
   
        'Get name of form
        sName = CurrentDb.Containers("Forms").Documents(i).Name
       
        'Open for for design
        DoCmd.OpenForm sName, acDesign
       
        'Change property
        Forms(sName).Properties("AllowDesignChanges") = False
       
        'Save
        DoCmd.Close acForm, sName, acSaveYes
    Next i

0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 400 total points
ID: 33697860
Just be aware that in some cases making design view changes to the DB via code will decomplile it.
You may want to go into the VBE and click: Debug-->Compile, then run the Compact and Repair utility after you run the above code, ...just to be on the safe side.

;-)

JeffCoachman
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33697871
The other issue might be subforms. if parent form opened already then that would open the subform.
I think the docmd.close should handle that but worth a check anyways
0
 
LVL 75
ID: 33698196
"AllowDesignChanges"
This is the 2nd time today this has come up.

1) If you create an MDE, this becomes a non-issue if you are trying to avoid this.

2) Why do you want to do this - just curious ?

mx
0
 
LVL 1

Author Comment

by:Milewskp
ID: 33715720
Hi Mx,
<Why do you want to do this - just curious ?>
I rarely use the properties sheet in form view, but I find it keeps popping up while I developing the forms.
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 400 total points
ID: 33717726
The Properties box will only show up when you open it, and don't close it.
If you have the Properties box open in "Form" or "Design" View it will always be there whenever you open any other forms.
If you close it, it will not.

So if you open the properties box then close it, it should never "keep popping up".

I don't know if I would use code like this instead of just closing the Properties box.
Remember, it will decompile your code, and I don't know if this will even work if you converted the App to an MDE (accde) file.

What version of Access are you using? What is your database format?

For me, in Access 2007, the property box never appears in Form view anyway, so this code may cause issues if/when you upgrade to Access 2007.

Are you saying that the only reason you want this is to prevent the property box from appearing in Form view?
Again, I don't know if I would do something as drastic as this.

However, if your goal is to really set all the forms so that you can only make Form design changes in Design view, then this should be fine.

JeffCoachman
0
 
LVL 1

Author Comment

by:Milewskp
ID: 33718149
Hi Jeff, I'm using Access 2003 SP3. Not sure what you mean about format.

<Are you saying that the only reason you want this is to prevent the property box from appearing in Form view?>
Yes
0
 
LVL 75
ID: 33718328
"I rarely use the properties sheet in form view,"
Then how do you design forms ?

mx
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33718807
MX,

I think they mean that they don't make any design changes to a form in "Form View"
They only make these changes in "Design View"...

Jeff
0
 
LVL 75
ID: 33718880
I see.

For me, the AllowDesignChanges in Form View was one of the best UI changes ever made to Access!

mx
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33719455
I see your point.
Being that you develop the app then make an MDE out of it.

But as you know, many people still push MDB files out to the users.
And at best, having the prop sheet pop up is annoying, ...at worst, users can make changes to the form's design.
:-O

I do know that Total Access analyzer will flag all forms that are set to allow form view changes...
probably for that reason...

So I am with you on your original post:
<If you create an MDE, this becomes a non-issue if you are trying to avoid this.>

But I also see the value in code that will make this change...

So I'll bow out now and let the asker evaluate the two options presented.

;-)

Jeff
0
 
LVL 75
ID: 33719521
"And at best, having the prop sheet pop up is annoying, ...at worst, users can make changes to the form's design."

Well yeah, but ... with your own custom menus that's a non issue.  Just set the property to No.

"But I also see the value in code that will make this change...'
You probably have to add that as a Custom db Property, similar to ... You 'see' the Description area for a Field in Table design view, but ... until you add that as a custom property, you cannot read/write to it.

mx
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33719591
MX

In Access 2007 (on an 2003 format DB) I don't see this setting.

Is this gone in 2007?
0
 
LVL 75
ID: 33719611
ahhh ... well, I HOPE not!  You mean in Form Design view, you don't see that property ???

I will check A2010 tonight ...

mx
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33721221
I mean the "AllowDesignChanges" property
I don't see this in Access 2007
0
 
LVL 75
ID: 33721248
This (attached):

?
Capture1.gif
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33721482
I don't get that in Access 2007 with mdb or accdb files?
(please confirm)
Is your screenshot above from Acc 2010?

This is what I get:

What am I doing wrong?


untitled.JPG
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 75
ID: 33722342
"Is your screenshot above from Acc 2010?"
That was A2003.  However, I just checked A2010 (don't have 2007).  I see what's happened.  Allow Design Changes has been replaced with Allow Layout View (on the Format tab). So, if you open the form in Layout View, then the Property sheet appears.  

And better yet, in Layout View, you can actually move controls around, in addition to making changes on the Property sheet.  This is  VERY COOL.  So ... essentially an extension of Allow Design Changes.

mx
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33722468
OK,

I thought I was going crazy for a moment there...

;-)

Jeff
0
 
LVL 75
ID: 33722479
And you had me SCARED, lol !!!
0
 
LVL 1

Author Comment

by:Milewskp
ID: 33724539
Hi all,
It looks like the answer to my original question <Is there a faster way? > is no, so let me rephrase:

 - Why does the prop sheet sometimes appear when I open a form in forms view, and sometimes not? If I could control this, it may solve my problem.

 - Is there a quick way to keep the properties sheet from popping up in forms view?For example, is there a way to set the default value of the AllowDesignChanges for new forms to Design Only. And if I do this, will this always and forever prevent the prop sheet from appearing in forms view?


Again, this is not so much a problem for my users as it is for me: while I'm developing forms, I'd like the prop sheet to pop up only when I want it to.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33725780
As I stated...
In Access 2003, If you open the property box and go into Form View, the Property box will remain open.
If you then close the form "without first closing the property box" then every time you open a form, the property box will appear.

So the simple answer is to close the property box when you are done with it.
(There are other properties you can set to get around this, but i don't want to muddy the waters anymore.)

But getting back on track...
As MX stated, If you push out MDE/accde files to your users, then this will not even be an issue...

The code rockiroads posted will do what you asked and it is a great snippet to have around and.

I just wanted to make sure I understood what your ultimate goal was.

JeffCoachman
0
 
LVL 1

Author Comment

by:Milewskp
ID: 33726961
Hi Jeff,
<I just wanted to make sure I understood what your ultimate goal was.>
while I'm developing forms, I'd like the prop sheet to pop up only when I want it to.
0
 
LVL 75
ID: 33726971
"- Why does the prop sheet sometimes appear when I open a form in forms view, and sometimes not?"
Because:
If the Allow Design Changes Property on the form is set to Yes ... AND ... when working on design view you have the Form property sheet open, then close the Form ... the next time you open the Form in form view, the property sheet will pop up.  And vice-versa.

mx

0
 
LVL 75
ID: 33726991
CLARIFICATION:

"If the Allow Design Changes Property on the form is set to Yes"
s/b >>> If the Allow Design Changes Property on the form is set to All Views  

"I'd like the prop sheet to pop up only when I want it to."
That is totally under your control, by setting the ADC property to All Views or Design View Only.

mx

0
 
LVL 1

Author Comment

by:Milewskp
ID: 33727057
Thanks Jeff and mx,
OK, I think I get it:  The Properties sheet will appear when you open a form in form view if AllowDesignChanges=Yes and the Properties sheet was open the last time you closed any form of the database, and closing the Property sheet before you close a form will prevent the Property sheet from appearing when you open another form. That works for me. Thanks.
0
 
LVL 75
ID: 33727136
AllowDesignChanges=Yes >> AllowDesignChanges= 'All Views'

Try Rocki's code to see if you can control that setting for deployment ...

mx
0
 
LVL 75
ID: 33727179
I just tried Rocki's code and it definitely does the job, as to be EXPECTED :-)

COOL.

mx
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33727652
Hi guys, sorry out of the loop for a while but nice conversation between mx and Jeff. Didnt want to intrude you know, three's a crowd and all that :)

mx. the code I got is not 100% foolproof but its a start. This kind of task would be like a one off.
Issue might be if you got subforms.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33727819
Hey rock, I had already bowed out, as my posts were just "clarifications"

You and MX provided solid solutions.

(besides, I learned a little something in this post as well, so it was worth stopping by...)

;-)

Jeff

0
 
LVL 75
ID: 33727954
"three's a crowd and all that :)"
Depends on the crowd :-)

"Issue might be if you got subforms."
Ummm ... should not be, because there are still just regular forms on the Forms container.

mx
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33728581
lol Jeff.

mx, if u open up a form in with a subform in design view then later on try to open that subform


Depends on the crowd :-)
yea, bet you don't mind your female roadies ;)
0
 
LVL 75
ID: 33728696
I just tried this with no issue.
frm4A is a subform on frm_Joe.
Both forms had prop changed ok.
Female Roadies = In a parallel universe.


Public Function aaaTest6()
 
    Dim i As Integer
    Dim sName As String
   
    'Go thru list
    For i = 0 To CurrentDb.Containers("Forms").Documents.Count - 1
   
        'Get name of form
        sName = CurrentDb.Containers("Forms").Documents(i).Name
        If sName = "frm_Joe" Or sName = "frm4A" Then
            'Open for for design
             DoCmd.OpenForm sName, acDesign
       
         'Change property
            Forms(sName).Properties("AllowDesignChanges") = False
       
            'Save
            DoCmd.Close acForm, sName, acSaveYes
        End If
    Next i

End Function
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33728805
thanks mx, you'll make a great QA person one day ;)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now