Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default Initializing Userform not working

I have a userform with optionbutton3 that will make certain labels/textboxes
invisible when TRUE. If optionbutton3 is TRUE and then user clicks FINISHED,
the userform will HIDE.

The problem is when the userform is executed again and those
labels/textboxes are still invisible. I appreciate any input on how to fix
this!

Below are two macros. The first shows the userform. The second is the one
that should initialize the userform, making all visible:

Sub TimeCalc()
Dim TextBox1 As String
Dim TextBox2, TextBox3 As String
TimeCalcFm.Show
End Sub


Private Sub UserForm_Initialize()
Me.Label1.Caption = "Enter Date Worked"
Me.Label2.Visible = True
Me.Label3.Visible = True
Me.Label4.Visible = True
Me.TextBox2.Visible = True
Me.TextBox3.Visible = True
Me.TextBox1 = ""
Me.TextBox2 = ""
Me.TextBox3 = ""
Me.OptionButton1.Value = True
Me.TextBox1.SetFocus
End Sub

Thanks,
Les
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Initializing Userform not working

What do you want to happen when you click option button 3? The code that is
displayed appears to be performing as written by your description. There is
nothing in the code to either hide or close the individual controls. If you
do not want them to appear when the userform is called, then you would have
to delete them from the initialize event and use the Add method to put them
on the form each time, with additional code to hide or close them.

"WLMPilot" wrote:

I have a userform with optionbutton3 that will make certain labels/textboxes
invisible when TRUE. If optionbutton3 is TRUE and then user clicks FINISHED,
the userform will HIDE.

The problem is when the userform is executed again and those
labels/textboxes are still invisible. I appreciate any input on how to fix
this!

Below are two macros. The first shows the userform. The second is the one
that should initialize the userform, making all visible:

Sub TimeCalc()
Dim TextBox1 As String
Dim TextBox2, TextBox3 As String
TimeCalcFm.Show
End Sub


Private Sub UserForm_Initialize()
Me.Label1.Caption = "Enter Date Worked"
Me.Label2.Visible = True
Me.Label3.Visible = True
Me.Label4.Visible = True
Me.TextBox2.Visible = True
Me.TextBox3.Visible = True
Me.TextBox1 = ""
Me.TextBox2 = ""
Me.TextBox3 = ""
Me.OptionButton1.Value = True
Me.TextBox1.SetFocus
End Sub

Thanks,
Les

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default Initializing Userform not working

The code that executes when Optionbutton3 is clicked works fine, which is why
I did not show it. The userform is designed to allow a user (me) to enter
and date,
time-in, and time-out from work. When ENTER is clicked, a macro will
calculate and place in a spreadsheet the appropriate time worked (in hours).
The three optionbuttons are 1-ENTER TIME 2-Correct Time (in entered in
error) and
3-Clear Time (in wrong date entered).

If optionbutton3 is TRUE, then the labels and textboxes used to obtain time
in and out become invisible because they are not necessary to clear time.

As stated, if optionbutton3 is TRUE and I click FINISHED (hide userform) and
later come back and click commandbutton to display userform and enter data,
the fields that were invisible are still invisible.

Hope this helps.
Les

"JLGWhiz" wrote:

What do you want to happen when you click option button 3? The code that is
displayed appears to be performing as written by your description. There is
nothing in the code to either hide or close the individual controls. If you
do not want them to appear when the userform is called, then you would have
to delete them from the initialize event and use the Add method to put them
on the form each time, with additional code to hide or close them.

"WLMPilot" wrote:

I have a userform with optionbutton3 that will make certain labels/textboxes
invisible when TRUE. If optionbutton3 is TRUE and then user clicks FINISHED,
the userform will HIDE.

The problem is when the userform is executed again and those
labels/textboxes are still invisible. I appreciate any input on how to fix
this!

Below are two macros. The first shows the userform. The second is the one
that should initialize the userform, making all visible:

Sub TimeCalc()
Dim TextBox1 As String
Dim TextBox2, TextBox3 As String
TimeCalcFm.Show
End Sub


Private Sub UserForm_Initialize()
Me.Label1.Caption = "Enter Date Worked"
Me.Label2.Visible = True
Me.Label3.Visible = True
Me.Label4.Visible = True
Me.TextBox2.Visible = True
Me.TextBox3.Visible = True
Me.TextBox1 = ""
Me.TextBox2 = ""
Me.TextBox3 = ""
Me.OptionButton1.Value = True
Me.TextBox1.SetFocus
End Sub

Thanks,
Les

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Initializing Userform not working

Really there are 2 ways to go here depending on what you are wanting to do.

The initialize event is only triggered when the userform is first created.
Unhiding the userform does not trigger the event. Oddly enough the .show
method either creates an instance of the user form or it unhides the existing
instance. The Activate event fires when the userform is unhidden. So you
might be able to add code to the activate event to solve your problem. This
all assumes that you truely want to hide the existing instance of the form.
This is true when you want the end user to see the form exactly as they left
it when they last used it.

If you want the form to be reinitialized each time clearing out what the
user last entered then instead of hiding the form you should Unload (delete)
it. This completely gets rid of the form so that the next time .show is
called a new instance of the form will be created and the initialize event
will fire....
--
HTH...

Jim Thomlinson


"WLMPilot" wrote:

I have a userform with optionbutton3 that will make certain labels/textboxes
invisible when TRUE. If optionbutton3 is TRUE and then user clicks FINISHED,
the userform will HIDE.

The problem is when the userform is executed again and those
labels/textboxes are still invisible. I appreciate any input on how to fix
this!

Below are two macros. The first shows the userform. The second is the one
that should initialize the userform, making all visible:

Sub TimeCalc()
Dim TextBox1 As String
Dim TextBox2, TextBox3 As String
TimeCalcFm.Show
End Sub


Private Sub UserForm_Initialize()
Me.Label1.Caption = "Enter Date Worked"
Me.Label2.Visible = True
Me.Label3.Visible = True
Me.Label4.Visible = True
Me.TextBox2.Visible = True
Me.TextBox3.Visible = True
Me.TextBox1 = ""
Me.TextBox2 = ""
Me.TextBox3 = ""
Me.OptionButton1.Value = True
Me.TextBox1.SetFocus
End Sub

Thanks,
Les

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default Initializing Userform not working

THANKS!!! Unload is what I needed.

Les


"Jim Thomlinson" wrote:

Really there are 2 ways to go here depending on what you are wanting to do.

The initialize event is only triggered when the userform is first created.
Unhiding the userform does not trigger the event. Oddly enough the .show
method either creates an instance of the user form or it unhides the existing
instance. The Activate event fires when the userform is unhidden. So you
might be able to add code to the activate event to solve your problem. This
all assumes that you truely want to hide the existing instance of the form.
This is true when you want the end user to see the form exactly as they left
it when they last used it.

If you want the form to be reinitialized each time clearing out what the
user last entered then instead of hiding the form you should Unload (delete)
it. This completely gets rid of the form so that the next time .show is
called a new instance of the form will be created and the initialize event
will fire....
--
HTH...

Jim Thomlinson


"WLMPilot" wrote:

I have a userform with optionbutton3 that will make certain labels/textboxes
invisible when TRUE. If optionbutton3 is TRUE and then user clicks FINISHED,
the userform will HIDE.

The problem is when the userform is executed again and those
labels/textboxes are still invisible. I appreciate any input on how to fix
this!

Below are two macros. The first shows the userform. The second is the one
that should initialize the userform, making all visible:

Sub TimeCalc()
Dim TextBox1 As String
Dim TextBox2, TextBox3 As String
TimeCalcFm.Show
End Sub


Private Sub UserForm_Initialize()
Me.Label1.Caption = "Enter Date Worked"
Me.Label2.Visible = True
Me.Label3.Visible = True
Me.Label4.Visible = True
Me.TextBox2.Visible = True
Me.TextBox3.Visible = True
Me.TextBox1 = ""
Me.TextBox2 = ""
Me.TextBox3 = ""
Me.OptionButton1.Value = True
Me.TextBox1.SetFocus
End Sub

Thanks,
Les



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
Initializing UserForm CMcK Excel Programming 1 October 22nd 06 09:29 PM
Userform initializing problem when opening Cajeto 63 Excel Programming 4 October 19th 06 08:10 PM
stop userform from initializing JT[_2_] Excel Programming 3 March 4th 05 07:18 PM
Initializing Combobox in a Userform Neal[_5_] Excel Programming 2 September 15th 04 12:19 AM
Initializing Userform Szadkowski Excel Programming 1 August 31st 04 12:35 AM


All times are GMT +1. The time now is 12:07 AM.

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

About Us

"It's about Microsoft Excel"