Reset all contols on a form?

  • Thread starter Thread starter Forbes Tucker
  • Start date Start date
F

Forbes Tucker

Is there a method to reset all the controls on a form to
the state (ie, enabled/disabled) they were in when the
form is initially opened? I have many enabled, many
disabled, and want to reset them all, without having to
do them individually.

Thanks,
Forbzy
 
You mean at runtime?

This code would save the initial value of the Enabled property of each
control, into its Tag property, as the string "True" or "False":

(untested)

dim ctl as control
for each ctl in me.controls
on error resume next ' might not have Enabled prop.
ctl.tag = ctl.enabled
on error goto 0
next

This code would restore the original settings:
for each ctl in me.controls
on error resume next ' might not have Enabled prop.
ctl.enabled = (ctl.tag = "true")
on error goto 0
next

HTH,
TC
 
Back
Top