Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Running a module from within a UserForm


From within UserForm2 when I click on OptionButton1 I want the MakeVisable
code (shown below) to run. The problem is that I get an "object required"
error. What do I need to add?

Private Sub OptionButton1_Click()

Call MakeVisable.MakeVisable

End Sub



Sub MakeVisable()

Label8.Visible = True
Label9.Visible = True

TextBox3.Visible = True
TextBox4.Visible = True

TextBox3.Value = Format$(Now(), "HH:MM")
TextBox4.Value = Format$(Now(), "mm/dd/yy")


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default Running a module from within a UserForm


Your module doesn't know where the controls it's supposed to change are
located. You can put your MakeVisable sub in the code sheet for the userform:

Private Sub OptionButton1_Click()
Call MakeVisable
End Sub

Sub MakeVisable()
Me.Label8.Visible = True
Me.Label9.Visible = True
Me.TextBox3.Visible = True
Me.TextBox4.Visible = True
Me.TextBox3.Value = Format$(Now(), "HH:MM")
Me.TextBox4.Value = Format$(Now(), "mm/dd/yy")
End Sub

Or, you can leave it in the MakeVisable VBA module if you make modifications
like the following:

'(in the userform code sheet)
Private Sub OptionButton1_Click()
Call MakeVisable.MakeVisable(Me)
End Sub

'(in the MakeVisable module)
Sub MakeVisable(MyForm As UserForm)
MyForm.Label8.Visible = True
MyForm.Label9.Visible = True
MyForm.TextBox3.Visible = True
MyForm.TextBox4.Visible = True
MyForm.TextBox3.Value = Format$(Now(), "HH:MM")
MyForm.TextBox4.Value = Format$(Now(), "mm/dd/yy")
End Sub

Hope this helps,

Hutch

"Patrick C. Simonds" wrote:

From within UserForm2 when I click on OptionButton1 I want the MakeVisable
code (shown below) to run. The problem is that I get an "object required"
error. What do I need to add?

Private Sub OptionButton1_Click()

Call MakeVisable.MakeVisable

End Sub



Sub MakeVisable()

Label8.Visible = True
Label9.Visible = True

TextBox3.Visible = True
TextBox4.Visible = True

TextBox3.Value = Format$(Now(), "HH:MM")
TextBox4.Value = Format$(Now(), "mm/dd/yy")


End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Running a module from within a UserForm


Thank you sir, that was exactly what I needed. I opted for option 1.

"Tom Hutchins" wrote in message
...
Your module doesn't know where the controls it's supposed to change are
located. You can put your MakeVisable sub in the code sheet for the
userform:

Private Sub OptionButton1_Click()
Call MakeVisable
End Sub

Sub MakeVisable()
Me.Label8.Visible = True
Me.Label9.Visible = True
Me.TextBox3.Visible = True
Me.TextBox4.Visible = True
Me.TextBox3.Value = Format$(Now(), "HH:MM")
Me.TextBox4.Value = Format$(Now(), "mm/dd/yy")
End Sub

Or, you can leave it in the MakeVisable VBA module if you make
modifications
like the following:

'(in the userform code sheet)
Private Sub OptionButton1_Click()
Call MakeVisable.MakeVisable(Me)
End Sub

'(in the MakeVisable module)
Sub MakeVisable(MyForm As UserForm)
MyForm.Label8.Visible = True
MyForm.Label9.Visible = True
MyForm.TextBox3.Visible = True
MyForm.TextBox4.Visible = True
MyForm.TextBox3.Value = Format$(Now(), "HH:MM")
MyForm.TextBox4.Value = Format$(Now(), "mm/dd/yy")
End Sub

Hope this helps,

Hutch

"Patrick C. Simonds" wrote:

From within UserForm2 when I click on OptionButton1 I want the
MakeVisable
code (shown below) to run. The problem is that I get an "object required"
error. What do I need to add?

Private Sub OptionButton1_Click()

Call MakeVisable.MakeVisable

End Sub



Sub MakeVisable()

Label8.Visible = True
Label9.Visible = True

TextBox3.Visible = True
TextBox4.Visible = True

TextBox3.Value = Format$(Now(), "HH:MM")
TextBox4.Value = Format$(Now(), "mm/dd/yy")


End Sub


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
2 Macros running on same module Travis Excel Worksheet Functions 2 May 6th 08 12:46 PM
running code only in selected module lawebster Excel Programming 1 June 19th 07 11:49 AM
Running a procedure in a module on graph change tobriant[_8_] Excel Programming 0 November 7th 05 06:49 PM
Running Standard Module Code from Dataform Jim May Excel Programming 1 September 29th 05 04:08 PM
Running Excel module within Access Id10 Terror Excel Programming 1 September 11th 05 07:50 PM


All times are GMT +1. The time now is 02:46 PM.

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"