Changing form properties for All forms (1 Viewer)

SmallTime

Registered User.
Local time
Yesterday, 23:45
Joined
Mar 24, 2011
Messages
246
Hi

Using 2010 32 bit

I need to change the following form properties to false for a large number of forms and was wondering if anyone knew how to do this through code and iterate through all forms in the database.

Allow DateSheet View
Allow PivotTable View
Allow PivotChart View
Allow Layout View

I have a bout 7 databases each with about 100 forms so want to avoid doing it manually if possible.


SmallTime
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 07:45
Joined
Sep 12, 2006
Messages
15,736
there may be other ways, but i use document containers.

eg I think there is now currentproject.allforms that does the same thing.

Code:
dim doc as document
dim db as database
 
set db=currentdb
 
for each doc in db.containers("forms").documents
'this iterates all the forms
'now you can open each one in desgin mode, make your changes, and save it.
     formname = doc.name
next


hope this helps
 

SmallTime

Registered User.
Local time
Yesterday, 23:45
Joined
Mar 24, 2011
Messages
246
Thanks Dave.

It's a start and should make the changes a less time consuming

Ta
SmallTime
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 07:45
Joined
Sep 12, 2006
Messages
15,736
you can certainly change the properties you need to change automatically

once you get a formname you can then do

docmd.openform formname, acdesign (or similar)
set properties for the form in code
docmd.closeform formname,acsaveyes
doevents

the doevents tidies up the display, otherwsie form images proliferate on oyur screen
 

SmallTime

Registered User.
Local time
Yesterday, 23:45
Joined
Mar 24, 2011
Messages
246
Fantastic,

I'll play around with it in a while (just need to do homework with the kids first).

Grateful thanks
SmallTime
 

SmallTime

Registered User.
Local time
Yesterday, 23:45
Joined
Mar 24, 2011
Messages
246
Many thanks, worked beautifully. Saved me hours of repetitive stuff.

In case anyone else wants to do the same thing here's how I ran Dave's code

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

Forms(strForm).AllowDatasheetView = False
Forms(strForm).AllowPivotTableView = False
Forms(strForm).AllowPivotChartView = False
Forms(strForm).AllowLayoutView = False
DoEvents
DoCmd.Close acForm, strForm, acSaveYes
Next doc


My regards to Gemma
SmallTime
 
Last edited:

Users who are viewing this thread

Top Bottom