Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default User Forms - Command Button defines value to be used later

I have a very basic User Form and I can get it to display. This is the
limited code I have within the user form:

Private Sub cmdMonthly_Click()
Dim Inchstone As String
Inchstone = "Monthly"
Unload Me
End Sub

Private Sub cmdWeekly_Click()
Dim Inchstone As String
Inchstone = "Weekly"
Unload Me
End Sub

I've tried to find info on User Forms but haven't found anything related to
this. How do I get the value of Inchstone back into the main code from
which I call the user form? Again, if I've done something wrong, please let
me know.

Thanks in advance,
Barb Reinhardt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default User Forms - Command Button defines value to be used later

Maybe...

Dim InchStone as String
Private Sub cmdMonthly_Click()
Inchstone = "Monthly"
End Sub
Private Sub cmdWeekly_Click()
Inchstone = "Weekly"
End Sub

When you declare InchStone outside any procedure, then any procedure in that
module can see it (and change it or read it).

(Unloading the form didn't seem like what you wanted to do...)

Barb Reinhardt wrote:

I have a very basic User Form and I can get it to display. This is the
limited code I have within the user form:

Private Sub cmdMonthly_Click()
Dim Inchstone As String
Inchstone = "Monthly"
Unload Me
End Sub

Private Sub cmdWeekly_Click()
Dim Inchstone As String
Inchstone = "Weekly"
Unload Me
End Sub

I've tried to find info on User Forms but haven't found anything related to
this. How do I get the value of Inchstone back into the main code from
which I call the user form? Again, if I've done something wrong, please let
me know.

Thanks in advance,
Barb Reinhardt


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default User Forms - Command Button defines value to be used later

Dave,

When I took the "UNLOAD" out, the form never goes away. What might be the
problem?

Thanks,
Barb

"Dave Peterson" wrote:

Maybe...

Dim InchStone as String
Private Sub cmdMonthly_Click()
Inchstone = "Monthly"
End Sub
Private Sub cmdWeekly_Click()
Inchstone = "Weekly"
End Sub

When you declare InchStone outside any procedure, then any procedure in that
module can see it (and change it or read it).

(Unloading the form didn't seem like what you wanted to do...)

Barb Reinhardt wrote:

I have a very basic User Form and I can get it to display. This is the
limited code I have within the user form:

Private Sub cmdMonthly_Click()
Dim Inchstone As String
Inchstone = "Monthly"
Unload Me
End Sub

Private Sub cmdWeekly_Click()
Dim Inchstone As String
Inchstone = "Weekly"
Unload Me
End Sub

I've tried to find info on User Forms but haven't found anything related to
this. How do I get the value of Inchstone back into the main code from
which I call the user form? Again, if I've done something wrong, please let
me know.

Thanks in advance,
Barb Reinhardt


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default User Forms - Command Button defines value to be used later

Ah, you're opening another userform to get this value?

Move that
Dim InchStone as String
from the top of the userform module
to the top of a General module
And make this change:
Public InchStone as String

That Public means that it can be seen everywhere.

(and add the unload me stuff back.)

Barb Reinhardt wrote:

Dave,

When I took the "UNLOAD" out, the form never goes away. What might be the
problem?

Thanks,
Barb

"Dave Peterson" wrote:

Maybe...

Dim InchStone as String
Private Sub cmdMonthly_Click()
Inchstone = "Monthly"
End Sub
Private Sub cmdWeekly_Click()
Inchstone = "Weekly"
End Sub

When you declare InchStone outside any procedure, then any procedure in that
module can see it (and change it or read it).

(Unloading the form didn't seem like what you wanted to do...)

Barb Reinhardt wrote:

I have a very basic User Form and I can get it to display. This is the
limited code I have within the user form:

Private Sub cmdMonthly_Click()
Dim Inchstone As String
Inchstone = "Monthly"
Unload Me
End Sub

Private Sub cmdWeekly_Click()
Dim Inchstone As String
Inchstone = "Weekly"
Unload Me
End Sub

I've tried to find info on User Forms but haven't found anything related to
this. How do I get the value of Inchstone back into the main code from
which I call the user form? Again, if I've done something wrong, please let
me know.

Thanks in advance,
Barb Reinhardt


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default User Forms - Command Button defines value to be used later

Thanks. That helps a lot. It's working the way I want now.

Barb

"Dave Peterson" wrote:

Ah, you're opening another userform to get this value?

Move that
Dim InchStone as String
from the top of the userform module
to the top of a General module
And make this change:
Public InchStone as String

That Public means that it can be seen everywhere.

(and add the unload me stuff back.)

Barb Reinhardt wrote:

Dave,

When I took the "UNLOAD" out, the form never goes away. What might be the
problem?

Thanks,
Barb

"Dave Peterson" wrote:

Maybe...

Dim InchStone as String
Private Sub cmdMonthly_Click()
Inchstone = "Monthly"
End Sub
Private Sub cmdWeekly_Click()
Inchstone = "Weekly"
End Sub

When you declare InchStone outside any procedure, then any procedure in that
module can see it (and change it or read it).

(Unloading the form didn't seem like what you wanted to do...)

Barb Reinhardt wrote:

I have a very basic User Form and I can get it to display. This is the
limited code I have within the user form:

Private Sub cmdMonthly_Click()
Dim Inchstone As String
Inchstone = "Monthly"
Unload Me
End Sub

Private Sub cmdWeekly_Click()
Dim Inchstone As String
Inchstone = "Weekly"
Unload Me
End Sub

I've tried to find info on User Forms but haven't found anything related to
this. How do I get the value of Inchstone back into the main code from
which I call the user form? Again, if I've done something wrong, please let
me know.

Thanks in advance,
Barb Reinhardt

--

Dave Peterson


--

Dave Peterson

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
user defines macro to run bwilk77 Excel Discussion (Misc queries) 4 March 23rd 07 09:26 PM
Forms Command Button - Removal JMay Excel Discussion (Misc queries) 8 January 4th 07 06:33 PM
Command button on forms Erik (AP Inc.) Excel Discussion (Misc queries) 2 August 28th 06 01:58 PM
how do you hide a forms command button Paul James[_3_] Excel Programming 4 September 5th 03 06:18 PM
Command Buttons on XL User Forms Hotbird Excel Programming 2 August 6th 03 01:42 PM


All times are GMT +1. The time now is 07:25 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"