I don't understand why you would need a load event with VBA? When the form is initialized, it is loaded into memory. VBA does not directly support MDI's so there is no need for a separate event in between Initialize and Activate. If I'm lost help me find the way.
The only time that you should worry about the Activate event firing too many times is when you show another Userform and then close it, activating the original userform. To prevent this you can use this:<pre>If Me.Visible = False then
'Code to run to initialize variables only one time
Thanks for sticking with me. I have a 'flair for flippancy' in my writing style sometimes so apologies if I've been a little brusque. Explanation refers to code sample below.
Dim myform As frmModal
Set myform = New frmModal
myform.Caption = "acanthus"
myform.VLdate = #1/1/2002#
I guess the simplest way to describe it is that after the initialise event, I have access to the form properties (to SEND values). When I do frm.show vbmodal I no longer have access (as the code execution is passed to the form). When the form 'UNLOADS' (and code execution returns to the calling code), I can also read these properties (to RETURN values) as the form is still in memory until I do
The LOAD event is the code that 'does something with' the values I've sent in to the form properties. (These may be standard prps such as caption or Property Let / Get.)
Hope I'm being clear - it's not an easy one to explain. As I say I can code around it.
Private mintTest As Integer
Private Sub CommandButton1_Click()
Me.TextBox1.Text = mintTest
Private Sub UserForm_Activate()
If Me.Visible = False Then
'quietly change something.
mintTest = 5
If this form has a button and a text box, the activate code never gets run. (XL 2000,W2000) Have I missed something.
But it seems also that you and Tom are correct in implying that excel activate is triggered much less than VB Activate.