USERFORM: What is the difference between Initialize and Activate routines?

Asked

Viewed 2,141 times

2

What’s the difference in using Initialize and Activate as a Userform boot routine?

  1. Private Sub UserForm_Initialize()
  2. Private Sub UserForm_Activate()

2 answers

3

Initalize occurs only once throughout the form execution so you can use, for example, to add items in a combo box, that is, to put codes that only need to be executed once before the form appears to the user. In the case of Activate, suppose you need to perform a validation every time the form is activated, in which case you would use Activate since it always runs when the form is activated

  • To be quite honest, I didn’t understand your explanation! Actually, I didn’t see any difference! How do they manage in practical terms? When you must use one instead of the other?

  • 1

    The Inhibit occurs only once throughout the form execution so you can use, for example, to add items in a combo box, that is, to put codes that only need to be executed once before the form appears to the user. In the case of Activate, Suppose you need to do a validation every time the form is activated, in which case you would use Activate since it always runs when the form is activated

  • 1

    Cool! It made more sense now! I suggest you update your response with this comment to make it more evident to the community ;)

0

The Boot occurs when the object (in your case the Form) is servant. Then the code runs only once. The Activate occurs every time the form’s Activate event occurs, that is, when it receives focus, or when it is displayed after it has been hidden, or any event that activates the object.

MS - Form.Activate Method reference

Browser other questions tagged

You are not signed in. Login or sign up in order to post.