+ Reply to Thread
Results 1 to 5 of 5

User Forms - Command Button defines value to be used later

  1. #1
    Barb Reinhardt
    Guest

    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. #2
    Dave Peterson
    Guest

    Re: 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. #3
    Barb Reinhardt
    Guest

    Re: 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. #4
    Dave Peterson
    Guest

    Re: 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. #5
    Barb Reinhardt
    Guest

    Re: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1