Access Tip of the Day


Programmatically toggle a control's Enabled property (Access 97/2000/2002)


You can enable or disable most controls by modifying the control's Enabled property. You can take advantage of that property's Boolean value settings by using a statement in the form

control.Enabled = Abs(control.Enabled) - 1

where control is the name of the object you're modifying. This statement simply switches the property between the two Boolean values, -1 and 0; -1 is enabled, and 0 is disabled.

You can also use the Not operator to switch a control's Enabled property. This technique uses True and False values instead of the Boolean values -1 and 0. The setup is basically the same, but the code is a little different. The Not technique uses a statement in the form

control.Enabled = Not control.Enabled

If the Enabled property is True, this statement changes it to False and vice versa.



(Content provided by Element K Journals)


(Note: Your browser is set to refuse cookies. As a result, you may frequently see previously-viewed tips)
 
PrintPrint CloseClose

Copyright © 2001 - 2025 MJ Technologies, LLC.  All rights reserved.