Automate Setting Form Properties

Tim L

Registered User.
Local time
Today, 13:08
Joined
Sep 6, 2002
Messages
414
Automate setting form properties?

Is it possible to automate the setting of form properties?

For example:
Develop a database, with lots of forms, reports etc run it, debug it get everything working fine, then decide to lock it down. Whilst locking the database down you want to change the "Min Max Buttons" property to "none" for all the forms/reports in your database. Also the "Control Box" to "No" etc.

My idea is for a bit of code that would set these (and other) properties for all of the forms, reports etc. automatically. Run it once and all locked down, run it again (or another bit of code) to reset the properties.

For example: would it be possible to obtain the names of all the forms in the host database (putting them in to an array or an automatically generated table) and then manipulate the properties using a loop? Is it possible to differeniate between forms and reports this way?

Would setting the properties in this manner be permanent, or would they need to be set everytime the database is opened?

Possibly a tough one this (I know I don't know enough code to even start) but hopefully one of gurus out there will see it as a challenge for the dark winter nights :-) Or be able to put me straight and tell me to stop dreaming <g>

Tim
 
Hi,

You don't need this code. When you create forms, disable the control box at that time and add a button that will function as an alternate way to close the form.

If you don't want users to close the forms at all, you might consider something like the following:

Dim frm as Form

For Each frm in Forms
frm.ControlBox =False
Next

However, a form is not in the forms collection unless it is loaded.


An alternative is to cut and paste the following code into the open event of all forms:


Me.ControlBox = False

This way the forms will always open with the control box disabled.

Thanks,

Mike
 
Thanks for your reply.

An alternative is to cut and paste the following code into the open event of all forms:

Me.ControlBox = False
Could I use this by referencing to a field in a table? So that I could set the field to either True or False to change the default behaviour?

Tim
 
Hi,

I just thought of something else. You can create a SQL statement that will show the name of all forms in the MSysObjects table. Look at the table to figure out what the ID code is for forms in the last field of the table; its -32768.

SELECT Name FROM MSysObjects WHERE Type = -32768

Create a recordset using this SQL and step through it. Load each form hidden, set its controlbox to False, and then close it.

However, I'm not sure if the controlbox property of the form will still be false the next time a form is loaded. The other problem with this, if you do it what you open the database, is that if you have many forms it will take a long time to finally load your startup form.

Mike
 
You can use a field. Say the table is tblProperties and the field is CtrlBox. You can use the following code:

me.ControlBox = DLookup("CtrlBox", "tblProperties")

This way it would be more flexible.
 

Users who are viewing this thread

Back
Top Bottom