Userform and Module

  • Thread starter Thread starter magix
  • Start date Start date
M

magix

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
 
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)
 
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)
 
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
 
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)
 
I just did in the previous post.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
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.
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top