+ Reply to Thread
Results 1 to 10 of 10

Userform and Module

  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
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >




  7. #7
    magix
    Guest

    Re: Userform and Module

    if that the case, how should I fix my code ? please guide. thanks.

    "Bob Phillips" <[email protected]> wrote in message
    news:[email protected]...
    > 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
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >




  8. #8
    Bob Phillips
    Guest

    Re: Userform and Module

    I just did in the previous post.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "magix" <[email protected]> wrote in message
    news:[email protected]...
    > if that the case, how should I fix my code ? please guide. thanks.
    >
    > "Bob Phillips" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >




  9. #9
    magix
    Guest

    Re: Userform and Module

    I know you are removing the calling module in OK Button Click event.

    Eventhough no bug, but it seems doesn't work the way I want.

    When click macro button, it will call the module function. In the beginning
    of the module, it will call the userform via "MyForm.Show" like the example
    below, after triggerring this userform, and ask for input from combo boxes.

    After make the selection, then ONLY by clicking OK, it will continue to
    process the rest of the code.
    E.g in example below, ONLY after clicking OK in MyForm, then it will proceed
    to DoingA. Currently it will no stop at MyForm.Show, but will execute the
    entire code.

    > > > sub MyTest()
    > > > ....
    > > > ....
    > > > MyForm.Show
    >>>> DoingA
    >>>> ....
    >>>> DoingB
    > > > ....
    > > > End Sub




    "Bob Phillips" <[email protected]> wrote in message
    news:%[email protected]...
    > I just did in the previous post.
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from email address if mailing direct)
    >
    > "magix" <[email protected]> wrote in message
    > news:[email protected]...
    > > if that the case, how should I fix my code ? please guide. thanks.
    > >
    > > "Bob Phillips" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > 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
    > > > > > > > >
    > > > > > > > >
    > > > > > > >
    > > > > > > >
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >




  10. #10
    Bob Phillips
    Guest

    Re: Userform and Module

    I don't understand. How would you expect it to move to DoingA without
    exiting the form?

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "magix" <[email protected]> wrote in message news:[email protected]...
    > I know you are removing the calling module in OK Button Click event.
    >
    > Eventhough no bug, but it seems doesn't work the way I want.
    >
    > When click macro button, it will call the module function. In the

    beginning
    > of the module, it will call the userform via "MyForm.Show" like the

    example
    > below, after triggerring this userform, and ask for input from combo

    boxes.
    >
    > After make the selection, then ONLY by clicking OK, it will continue to
    > process the rest of the code.
    > E.g in example below, ONLY after clicking OK in MyForm, then it will

    proceed
    > to DoingA. Currently it will no stop at MyForm.Show, but will execute the
    > entire code.
    >
    > > > > sub MyTest()
    > > > > ....
    > > > > ....
    > > > > MyForm.Show
    > >>>> DoingA
    > >>>> ....
    > >>>> DoingB
    > > > > ....
    > > > > End Sub

    >
    >
    >
    > "Bob Phillips" <[email protected]> wrote in message
    > news:%[email protected]...
    > > I just did in the previous post.
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > (remove nothere from email address if mailing direct)
    > >
    > > "magix" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > if that the case, how should I fix my code ? please guide. thanks.
    > > >
    > > > "Bob Phillips" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > 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