+ Reply to Thread
Results 1 to 10 of 10

Userform and Module

Hybrid View

  1. #1
    magix
    Guest

    Userform and Module

    Hi,

    I have a userform and a module with macro button. Is this the right way to
    call module from OK Button code ?

    In my userform (Form name is MyForm), OK button has following code
    Private Sub OKButton_Click()
    ....
    ....
    InputA = Me.ComboBox1.Value
    InputB = Me.ComboBox2.Value
    Module1.MyTest
    End Sub

    In my module, I have
    Option Explicit
    Public InputA As String
    Public InputB As String
    sub MyTest()
    ....
    ....
    MyForm.Show
    ....
    some function here to compare with InputA and Input B
    ....
    End Sub

    If I run, the debug code will stop at "MyForm.Show".
    What is wrong ?

    Thanks.

    Magix



  2. #2
    Bob Phillips
    Guest

    Re: Userform and Module

    Are you getting an error that it is already displayed, it looks as though
    you have a loop to me, the macro shows the form, which calls the macro,
    which shows the form ....

    BTW I get an error with InputA

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "magix" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I have a userform and a module with macro button. Is this the right way to
    > call module from OK Button code ?
    >
    > In my userform (Form name is MyForm), OK button has following code
    > Private Sub OKButton_Click()
    > ....
    > ....
    > InputA = Me.ComboBox1.Value
    > InputB = Me.ComboBox2.Value
    > Module1.MyTest
    > End Sub
    >
    > In my module, I have
    > Option Explicit
    > Public InputA As String
    > Public InputB As String
    > sub MyTest()
    > ....
    > ....
    > MyForm.Show
    > ....
    > some function here to compare with InputA and Input B
    > ....
    > End Sub
    >
    > If I run, the debug code will stop at "MyForm.Show".
    > What is wrong ?
    >
    > Thanks.
    >
    > Magix
    >
    >




  3. #3
    magix
    Guest

    Re: Userform and Module

    what would be the appropriate way then ? How to fix the code ?

    "Bob Phillips" <[email protected]> wrote in message
    news:[email protected]...
    > Are you getting an error that it is already displayed, it looks as though
    > you have a loop to me, the macro shows the form, which calls the macro,
    > which shows the form ....
    >
    > BTW I get an error with InputA
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from email address if mailing direct)
    >
    > "magix" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi,
    > >
    > > I have a userform and a module with macro button. Is this the right way

    to
    > > call module from OK Button code ?
    > >
    > > In my userform (Form name is MyForm), OK button has following code
    > > Private Sub OKButton_Click()
    > > ....
    > > ....
    > > InputA = Me.ComboBox1.Value
    > > InputB = Me.ComboBox2.Value
    > > Module1.MyTest
    > > End Sub
    > >
    > > In my module, I have
    > > Option Explicit
    > > Public InputA As String
    > > Public InputB As String
    > > sub MyTest()
    > > ....
    > > ....
    > > MyForm.Show
    > > ....
    > > some function here to compare with InputA and Input B
    > > ....
    > > End Sub
    > >
    > > If I run, the debug code will stop at "MyForm.Show".
    > > What is wrong ?
    > >
    > > Thanks.
    > >
    > > Magix
    > >
    > >

    >
    >




  4. #4
    Bob Phillips
    Guest

    Re: Userform and Module

    I would need to know what you are trying to do, but you have to break that
    loop.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "magix" <[email protected]> wrote in message
    news:[email protected]...
    > what would be the appropriate way then ? How to fix the code ?
    >
    > "Bob Phillips" <[email protected]> wrote in message
    > news:[email protected]...
    > > Are you getting an error that it is already displayed, it looks as

    though
    > > you have a loop to me, the macro shows the form, which calls the macro,
    > > which shows the form ....
    > >
    > > BTW I get an error with InputA
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > (remove nothere from email address if mailing direct)
    > >
    > > "magix" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Hi,
    > > >
    > > > I have a userform and a module with macro button. Is this the right

    way
    > to
    > > > call module from OK Button code ?
    > > >
    > > > In my userform (Form name is MyForm), OK button has following code
    > > > Private Sub OKButton_Click()
    > > > ....
    > > > ....
    > > > InputA = Me.ComboBox1.Value
    > > > InputB = Me.ComboBox2.Value
    > > > Module1.MyTest
    > > > End Sub
    > > >
    > > > In my module, I have
    > > > Option Explicit
    > > > Public InputA As String
    > > > Public InputB As String
    > > > sub MyTest()
    > > > ....
    > > > ....
    > > > MyForm.Show
    > > > ....
    > > > some function here to compare with InputA and Input B
    > > > ....
    > > > End Sub
    > > >
    > > > If I run, the debug code will stop at "MyForm.Show".
    > > > What is wrong ?
    > > >
    > > > Thanks.
    > > >
    > > > Magix
    > > >
    > > >

    > >
    > >

    >
    >




  5. #5
    magix
    Guest

    Re: Userform and Module

    very straight forward.
    When click the macro button, it will launch the userform, then user selects
    value from two combo boxes, let say:
    InputA and InputB
    then these two values will send to my module code, and do the remaining
    tasks, as specified in module.

    that's it. Which loop do you mean?

    regards,
    magix

    "Bob Phillips" <[email protected]> wrote in message
    news:[email protected]...
    > I would need to know what you are trying to do, but you have to break that
    > loop.
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from email address if mailing direct)
    >
    > "magix" <[email protected]> wrote in message
    > news:[email protected]...
    > > what would be the appropriate way then ? How to fix the code ?
    > >
    > > "Bob Phillips" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Are you getting an error that it is already displayed, it looks as

    > though
    > > > you have a loop to me, the macro shows the form, which calls the

    macro,
    > > > which shows the form ....
    > > >
    > > > BTW I get an error with InputA
    > > >
    > > > --
    > > > HTH
    > > >
    > > > Bob Phillips
    > > >
    > > > (remove nothere from email address if mailing direct)
    > > >
    > > > "magix" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > Hi,
    > > > >
    > > > > I have a userform and a module with macro button. Is this the right

    > way
    > > to
    > > > > call module from OK Button code ?
    > > > >
    > > > > In my userform (Form name is MyForm), OK button has following code
    > > > > Private Sub OKButton_Click()
    > > > > ....
    > > > > ....
    > > > > InputA = Me.ComboBox1.Value
    > > > > InputB = Me.ComboBox2.Value
    > > > > Module1.MyTest
    > > > > End Sub
    > > > >
    > > > > In my module, I have
    > > > > Option Explicit
    > > > > Public InputA As String
    > > > > Public InputB As String
    > > > > sub MyTest()
    > > > > ....
    > > > > ....
    > > > > MyForm.Show
    > > > > ....
    > > > > some function here to compare with InputA and Input B
    > > > > ....
    > > > > End Sub
    > > > >
    > > > > If I run, the debug code will stop at "MyForm.Show".
    > > > > What is wrong ?
    > > > >
    > > > > Thanks.
    > > > >
    > > > > Magix
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >




  6. #6
    Bob Phillips
    Guest

    Re: Userform and Module

    The loop whereby the macro shows the form, which calls the macro, which
    shows the form ....

    In my userform (Form name is MyForm), OK button has following code
    Private Sub OKButton_Click()
    ....
    ....
    InputA = Me.ComboBox1.Value
    InputB = Me.ComboBox2.Value
    End Sub

    In my module, I have
    Option Explicit
    Public InputA As String
    Public InputB As String
    sub MyTest()
    ....
    ....
    MyForm.Show
    ....
    some function here to compare with InputA and Input B
    ....
    End Sub

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "magix" <[email protected]> wrote in message
    news:[email protected]...
    > very straight forward.
    > When click the macro button, it will launch the userform, then user

    selects
    > value from two combo boxes, let say:
    > InputA and InputB
    > then these two values will send to my module code, and do the remaining
    > tasks, as specified in module.
    >
    > that's it. Which loop do you mean?
    >
    > regards,
    > magix
    >
    > "Bob Phillips" <[email protected]> wrote in message
    > news:[email protected]...
    > > I would need to know what you are trying to do, but you have to break

    that
    > > loop.
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > (remove nothere from email address if mailing direct)
    > >
    > > "magix" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > what would be the appropriate way then ? How to fix the code ?
    > > >
    > > > "Bob Phillips" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > Are you getting an error that it is already displayed, it looks as

    > > though
    > > > > you have a loop to me, the macro shows the form, which calls the

    > macro,
    > > > > which shows the form ....
    > > > >
    > > > > BTW I get an error with InputA
    > > > >
    > > > > --
    > > > > HTH
    > > > >
    > > > > Bob Phillips
    > > > >
    > > > > (remove nothere from email address if mailing direct)
    > > > >
    > > > > "magix" <[email protected]> wrote in message
    > > > > news:[email protected]...
    > > > > > Hi,
    > > > > >
    > > > > > I have a userform and a module with macro button. Is this the

    right
    > > way
    > > > to
    > > > > > call module from OK Button code ?
    > > > > >
    > > > > > In my userform (Form name is MyForm), OK button has following code
    > > > > > Private Sub OKButton_Click()
    > > > > > ....
    > > > > > ....
    > > > > > InputA = Me.ComboBox1.Value
    > > > > > InputB = Me.ComboBox2.Value
    > > > > > Module1.MyTest
    > > > > > End Sub
    > > > > >
    > > > > > In my module, I have
    > > > > > Option Explicit
    > > > > > Public InputA As String
    > > > > > Public InputB As String
    > > > > > sub MyTest()
    > > > > > ....
    > > > > > ....
    > > > > > MyForm.Show
    > > > > > ....
    > > > > > some function here to compare with InputA and Input B
    > > > > > ....
    > > > > > End Sub
    > > > > >
    > > > > > If I run, the debug code will stop at "MyForm.Show".
    > > > > > What is wrong ?
    > > > > >
    > > > > > Thanks.
    > > > > >
    > > > > > Magix
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >




+ 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