Disabling ALL controls on a form via a combo box

Rofey

New member
Local time
Today, 18:48
Joined
Aug 6, 2005
Messages
9
My database has a form with a combo box where the user can select whether the record displayed is "Current", "Sold", or "Withdrawn". I would like to set up the form so that when the user selects "Sold" or "Withdrawn" from the combo box, all other controls on the form are locked and disabled (ie. can't be changed).

What's the best way to do this?
 
Set the enabled property to False and the Locked property to True for all of your controls on the afterupdate event of the combobox.

You'll also need to write some code for the OnCurrent event of the form to look in the value of the combobox and set the controls to be enabled or not depending on what the combobox shows.

You could do each one individually, or you could loop through all controls on your form. It just depends if your really want to disable all of them or not.
 
Put this code in the forms OnCurrent event and also in the AfterUpdate event for your combo box.

Code:
If Me.ComboBox = "Withdrawn" Then
    Me.AllowAdditions = True
    Me.AllowDeletions = True
    Me.AllowEdits = True
Else 'ComboBox = "Current" or "sold"
    Me.AllowAdditions = False
    Me.AllowDeletions = False
    Me.AllowEdits = False
End Sub
 

Users who are viewing this thread

Back
Top Bottom