Command Buttons to dictate the status of a form?

Morpheus_UK

Registered User.
Local time
Today, 03:36
Joined
Dec 31, 2004
Messages
23
Is there a way to have one Command button on a form, say called UnLock, which is active (enabled + unlocked), and make everything else on the form Read Only.

When You press this UnLock Command button, it makes everything on the form that was Read Only, now editable.

There would be a second Comand button, say Lock (which is active once you pressed unlock) which makes everything Read Only again apart from the Unlock Command Button. Note it is a continous form, tabular, so it will have new records added.

I think this is to do with programming, but I have no experience there. Any suggestions on how to do this would be great. If its too much trouble, don't worry replying.
 
Is there a way to have one Command button on a form, say called UnLock, which is active (enabled + unlocked), and make everything else on the form Read Only.

Absolutely yes.


When You press this UnLock Command button, it makes everything on the form that was Read Only, now editable.

No problem if you don't mind a little VBA code.


There would be a second Comand button, say Lock (which is active once you pressed unlock) which makes everything Read Only again apart from the Unlock Command Button.

A little more VBA code. Looks JUST LIKE the other VBA code except that everything that was set to FALSE gets set to TRUE and everything that was set to TRUE gets set to FALSE.

Note it is a continous form, tabular, so it will have new records added.

NOW you are asking for a bit of work. Your buttons probably have to go into a form header section because you will have multiple buttons (one or two per record) in the detail section.

The OnClick routines for your buttons would be where the code goes. When you make a continuous form, the question is not only which fields are disabled for editing, but WHEN they are disabled.

I would take the approach of making a class-module routine to enable or disable all items in a list. The list might contain the name of each control and the property to be enabled or disabled. Like

Sub EDCtrl(State as Boolean)

[ctl1].enabled=State
[ctl2].enabled=State

etc. etc.

End Sub

BUT I would make the button routines set a variable to TRUE or FALSE and would make the form's OnCurrent routine call this routine. Now when you change focus from one row to another, you trigger OnCurrent routines that will check the state of the variable.

If you try to do this dynamically, there is a serious question as to which set of controls gets disabled or enabled.
 
Thats kool!

Thanks for the reply. It is very helpful on how I will go about doing this for my form.
 

Users who are viewing this thread

Back
Top Bottom