Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why are Userform_Initialize & Button_Click firing here???

Status
Not open for further replies.

tmktech

MIS
Oct 3, 2002
78
US
Howdy, Tek-Tippers! I'm at wit's end on this one and could really use some help.

Below is my Userform_INITIALIZE code

------------------------------------------------------
Private Sub Userform_initialize()
Align(0) = "0 - Top Left"
Align(1) = "1 - Top Right"
Align(2) = "2 - Center"
Align(3) = "3 - Bottom Left"
Align(4) = "4 - Bottom Right"

SpinButton1.Min = 0
SpinButton1.Max = 4
SpinButton1.Value = 0

Application.EnableEvents = False

TextBox1.Text = Align(ActiveSheet.Dynamic_Image.PictureAlignment)

Select Case ActiveSheet.Dynamic_Image.PictureSizeMode
Case fmPictureSizeModeClip
OptionButton1.Value = True
Case fmPictureSizeModeStretch
OptionButton2.Value = True
Case fmPictureSizeModeZoom
OptionButton3.Value = True
End Select

Select Case [Image_Source].Columns.Count
Case 3
OptionButton4.Value = True 'wide
Case 2
OptionButton5.Value = True 'square
Case 1
OptionButton6.Value = True 'tall
End Select

Application.EnableEvents = True

End Sub

--------------------------------------------------------

As expected, this routine fires properly upon loading - and prior to showing - the Userform.

Here's my two issues:

[1] Why is the initialize proc also firing when I UNLOAD the Userform????? And how can I STOP it?

[2] You'll notice two sets of OptionButtons (1 thru 3) and (4 thru 6) are in separate frames. Why are the Commandbuttons' CLICK events firing when I initialize the buttons' value (i.e. TRUE) ??? And how can I stop this too?

FYI - The Commandbutton CLICK code is not included, but is within a "Private Sub CommandButton1_Click ()"


T H A N K I N A D V A N C E ! ! ! !

TMKTECH
 
Hi tmktech,

1. The Initialize should not fire when you unload UNLESS the form is not currently loaded. Might you be unloading the form twice?

2. I'm afraid that's the way it works. You'll need to code to catch the situation if it matters to you. From Help ..

Occurs in one of two cases:

The user clicks a control with the mouse.

The user definitively selects a value for a control with more than one possible value.


...


Of the two cases where the Click event occurs, the first case applies to the CommandButton, Frame, Image, Label, ScrollBar, and SpinButton. The second case applies to the CheckBox, ComboBox, ListBox, MultiPage, TabStrip, and ToggleButton. It also applies to an OptionButton when the value changes to True.

Sorry not to be more helpful.

Enjoy,
Tony


 
Tony, Thanks for the confirmation.

I removed my explicit Unload and added an "initialize" switch to the Button_Click to ignore when set by the macro.

Just wanted to make sure I wasn't missing something.

Cheers.

TMKTECH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top