Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Event Management

Hi All

In a useform intialize event I set an OptionButton depending on the values
found in worksheet cells. On the same userform I have set up a click event
for the same OptionButton that if clicked Shows second userform.

If the OptionButton.value is set to 1 in the initialise event of the first
userform the second userfrom loads first and has to be cancelled before the
first userform opens. Clearly the OptionButton_Click event is being
triggered BEFORE the first form loads. I have tried to disable Application
events whilst the first userform is initialising without success.

Any ideas - how I can force the first useform to load, stop the OptionButton
click event from opening the second userform unless the OptionButton is
specifically clicked?

Sample code behind first userform.....

Private Sub UserForm_Initialize()
' load sheet value into controls
If ActiveCell(1, 2).Value = "Yes" Then
OptionButton1.Value = 1 ' the setting of this control triggers the
click event below!
End If
End Sub

Private Sub OptionButton1_Click()
UserForm2.Show
End Sub



--
Cheers
Nigel




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Event Management

Nigel,

Unfortunately, with forms, you have to do it all yourself.

With these type of click events, I add a Boolean, like so

Private fReEntry As Boolean


Private Sub OptionButton1_Click()
If Not fReEntry Then
fReEntry = True
UserForm2.Show
fReEntry = False
End If
End Sub

That is the general technique. It may be a bit overkill here, you can get
away with

Private Sub OptionButton1_Click()
If Not fReEntry Then
UserForm2.Show
End If
End Sub

but the first stops the control event re-firng itself in other conditions.

Then amend the Initialise like so

Private Sub UserForm_Initialize()
' load sheet value into controls
fReEntry = True
If ActiveCell(1, 2).Value = "Yes" Then
OptionButton1.Value = 1
End If
fReEntry = False
End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Nigel" wrote in message
...
Hi All

In a useform intialize event I set an OptionButton depending on the values
found in worksheet cells. On the same userform I have set up a click

event
for the same OptionButton that if clicked Shows second userform.

If the OptionButton.value is set to 1 in the initialise event of the first
userform the second userfrom loads first and has to be cancelled before

the
first userform opens. Clearly the OptionButton_Click event is being
triggered BEFORE the first form loads. I have tried to disable

Application
events whilst the first userform is initialising without success.

Any ideas - how I can force the first useform to load, stop the

OptionButton
click event from opening the second userform unless the OptionButton is
specifically clicked?

Sample code behind first userform.....

Private Sub UserForm_Initialize()
' load sheet value into controls
If ActiveCell(1, 2).Value = "Yes" Then
OptionButton1.Value = 1 ' the setting of this control triggers the
click event below!
End If
End Sub

Private Sub OptionButton1_Click()
UserForm2.Show
End Sub



--
Cheers
Nigel






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Event Management

Bob,
I just knew I would need to add some extra control logic you have pointed
the way. Many Thanks

--
Cheers
Nigel



"Bob Phillips" wrote in message
...
Nigel,

Unfortunately, with forms, you have to do it all yourself.

With these type of click events, I add a Boolean, like so

Private fReEntry As Boolean


Private Sub OptionButton1_Click()
If Not fReEntry Then
fReEntry = True
UserForm2.Show
fReEntry = False
End If
End Sub

That is the general technique. It may be a bit overkill here, you can get
away with

Private Sub OptionButton1_Click()
If Not fReEntry Then
UserForm2.Show
End If
End Sub

but the first stops the control event re-firng itself in other conditions.

Then amend the Initialise like so

Private Sub UserForm_Initialize()
' load sheet value into controls
fReEntry = True
If ActiveCell(1, 2).Value = "Yes" Then
OptionButton1.Value = 1
End If
fReEntry = False
End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Nigel" wrote in message
...
Hi All

In a useform intialize event I set an OptionButton depending on the

values
found in worksheet cells. On the same userform I have set up a click

event
for the same OptionButton that if clicked Shows second userform.

If the OptionButton.value is set to 1 in the initialise event of the

first
userform the second userfrom loads first and has to be cancelled before

the
first userform opens. Clearly the OptionButton_Click event is being
triggered BEFORE the first form loads. I have tried to disable

Application
events whilst the first userform is initialising without success.

Any ideas - how I can force the first useform to load, stop the

OptionButton
click event from opening the second userform unless the OptionButton is
specifically clicked?

Sample code behind first userform.....

Private Sub UserForm_Initialize()
' load sheet value into controls
If ActiveCell(1, 2).Value = "Yes" Then
OptionButton1.Value = 1 ' the setting of this control triggers the
click event below!
End If
End Sub

Private Sub OptionButton1_Click()
UserForm2.Show
End Sub



--
Cheers
Nigel








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Project Management Radiate Excel Discussion (Misc queries) 1 October 9th 06 02:53 PM
event management program Unigue eventer Excel Discussion (Misc queries) 1 April 2nd 05 09:01 PM
user form-on open event? keydown event? FSt1[_3_] Excel Programming 2 August 5th 04 02:26 PM
Event Procedures: Event on Worksheet to fire Event on another Worksheet Kathryn Excel Programming 2 April 7th 04 07:35 PM
OnTime event not firing in Workbook_Open event procedure GingerTommy Excel Programming 0 September 24th 03 03:18 PM


All times are GMT +1. The time now is 03:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"