Allow Design Changes -> Design View Only

ions

Access User
Local time
Today, 06:55
Joined
May 23, 2004
Messages
816
Dear MS Access Expert.

I am looking for the code to do the below process.

Open every form in the database in design view.
Set the Allow Design Changes property to Design View Only.


Thank you very much.
 
I didn't know it had this property. what tab is it on anyway? if you know, look it up in the help menu and you will get an example piece of code. then, loop through your forms, and use that example as a start of how to write the code to do this. If I knew where the property was in the first place, I'd look it up and give you the code right off.
 
Try;

Public Sub UpdateForms()
On Error Resume Next
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
'Search for open AccessObject objects in AllForms collection.
For Each obj In dbs.AllForms
DoCmd.OpenForm obj.Name, acDesign
If Forms(obj.Name).AllowDesignChanges = True Then
Debug.Print "Updating AllowDesignChanges for " & obj.Name
Forms(obj.Name).AllowDesignChanges = False
End If
DoCmd.Close acForm, obj.Name, acSaveYes
Next obj
End Sub

Or:

Public Sub turnOffFormProps()
Dim strForm As String, db As DAO.Database
Dim doc As DAO.Document
Set db = CurrentDb

For Each doc In db.Containers("Forms").Documents
strForm = doc.Name
DoCmd.OpenForm strForm, acDesign
Debug.Print Forms(strForm).Properties("AllowDesignChanges")
Forms(strForm).Properties("AllowDesignChanges") = False
DoCmd.Close acForm, strForm, acSaveYes
Next doc

Set doc = Nothing
db.Close
Set db = Nothing
End Sub
 
Last edited:
Thank you for replay.

What exactly does AllowDesignChanges = False do?

I have a Form "Customers" from Northwind mdb. It shows
AllowDesignChanges - False, but I can still alter the design an save the changes.

By the way nice code JPaulo.


Edit: Looked in help and found:

You can use the AllowDesignChanges property to specify or determine if design changes can be made to a form in all views or Design view only. Read/write Boolean.

expression.AllowDesignChanges
expression Required. An expression that returns one of the objects in the Applies To list.
 
Last edited:
after saving each form as per jpaulo's code

DoCmd.Close acForm, strForm, acSaveYes

you will probably need to add
doevents straight afterwards, so the screen refreshes tidily - otherwise you are likely to get a vision of dozens of apparently overlaid forms.
 
Ok Thanks Husky. Added the DoEvents as you suggested.
 

Users who are viewing this thread

Back
Top Bottom