B
Brian
I have a form on which certain controls (mostly combo boxes) are enabled or
disabled based on the value the user selects in a particular combo box (e.g.
a Vendor box is enabled and Customer box disabled if the ContractType =
"Purchase" and vice versa if ContractType = "Sale").
So...when ContractType changes, I enable/disable those two controls (these
are just two examples of probably a dozen different combinations involving
various controls, however). Rather than put the specific enable/disable with
each control, I wrote one procedure that checks the content of each of the
base controls and adjusts the enable/disable status of the related controls,
then call that procedure as necessary.
The problem is that if the user changes ContractType (thus triggering other
controls to be enabled/disabled), then presses ESC, ContractType changes back
to the original value, but the enable/disable of the related controls does
not change to match.
This means that ContractType_AfterUpdate is not a workable place to put the
enable/disable code. My solution to this point is to put all the
enable/disable code into the Form_Timer and have the Form_Timer fire every
1/2 second. Any longer than that, and the user might move into another box
before it is disabled, thus causing an error when the code attempts to
disable the box. Even so, I then had to write code to move the focus out of
any box before disabling it (moving the focus to a generic conrol that never
gets disabled).
While this works OK, it is not ideal because there are at least a dozen of
these combinations, and the enable/disable code running twice per second
tends to make the form function a little "jerkily".
I would try Form_Undo, but sometimes it is the Undo of the control, not the
form, that changes the value back. The only guaranteed solution I can think
of is to add the procedure call to the After_Update and Undo events of every
affected base control as well as the form's Undo event, and then I think I
might have to add it to the KeyPress of every base control as well, checking
for the ESC key.
Other ideas? This just makes my code seem really bulky and inefficient.
disabled based on the value the user selects in a particular combo box (e.g.
a Vendor box is enabled and Customer box disabled if the ContractType =
"Purchase" and vice versa if ContractType = "Sale").
So...when ContractType changes, I enable/disable those two controls (these
are just two examples of probably a dozen different combinations involving
various controls, however). Rather than put the specific enable/disable with
each control, I wrote one procedure that checks the content of each of the
base controls and adjusts the enable/disable status of the related controls,
then call that procedure as necessary.
The problem is that if the user changes ContractType (thus triggering other
controls to be enabled/disabled), then presses ESC, ContractType changes back
to the original value, but the enable/disable of the related controls does
not change to match.
This means that ContractType_AfterUpdate is not a workable place to put the
enable/disable code. My solution to this point is to put all the
enable/disable code into the Form_Timer and have the Form_Timer fire every
1/2 second. Any longer than that, and the user might move into another box
before it is disabled, thus causing an error when the code attempts to
disable the box. Even so, I then had to write code to move the focus out of
any box before disabling it (moving the focus to a generic conrol that never
gets disabled).
While this works OK, it is not ideal because there are at least a dozen of
these combinations, and the enable/disable code running twice per second
tends to make the form function a little "jerkily".
I would try Form_Undo, but sometimes it is the Undo of the control, not the
form, that changes the value back. The only guaranteed solution I can think
of is to add the procedure call to the After_Update and Undo events of every
affected base control as well as the form's Undo event, and then I think I
might have to add it to the KeyPress of every base control as well, checking
for the ESC key.
Other ideas? This just makes my code seem really bulky and inefficient.