Unable to close 2nd user form

R

RJQMAN

I am just beginning to learn how to use forms. I was able to get one
form to open and close fine, then I added a 2nd form. I admit I am
working by Rote, as I do not yet fully understand what I am coding.

Here is the code I use to open the 1st user form (I left out some
stuff that did not seem essential to the question).
Sub form1()
UserForm.Show
If UserForm.OptionButton1.Value = True Then Range("A10").Value = 7
If UserForm.OptionButton2.Value = True Then Range("A10").Value = 6
If Range("A10").Value = 6 Then Call ConfirmDecision
End Sub
------------------------------------------------------------------
Then in the forms coding, I put

Private Sub CommandButton1_Click()
UserForm.Hide
End Sub

Private Sub UserForm_Click()
End Sub
=======================================================
The 2nd form opens fine...but when I click on the button to try to
close it, I get an error message

UserForm1.Show

If UserForm1.OptionButton1.Value = True Then Range("B8").Value = 8
If UserForm1.OptionButton2.Value = True Then Range("B8").Value = 9
Range("F13").Select

Private Sub CommandButton1_Click()
UserForm1.Hide
End Sub

Private Sub UserForm1_Click()
End Sub

I have spent hours of trial and error. Any help would really be
appreciated.

RJQman
 
F

FSt1

hi,
from your code i see you are loading them as modal. when a form is modal, the
user must respond before using any other part of the application. No
subsequent code is executed until the form is hidden or unloaded. to set as
modaless...

Yourform.show 0

if you omit the zero, the form will load as modal. modal = 1. Modal is
default.

regards,
FSt1
 
T

Tom Ogilvy

I would rename my userforms. I wouldn't use the generic Userform as a name.
(for example rename the Userform named "Userform" to "Userform2").

Close excel and rename them after you open excel and before you run any code.

If you still have problems after you rename them, then you may need to run
Rob Bovey's code cleaner

http://www.appspro.com

should be under the free downloads.
 
R

RJQMAN

I would rename my userforms. I wouldn't use the generic Userform as a name.
(for example rename the Userform named "Userform" to "Userform2").

Close excel and rename them after you open excel and before you run any code.

If you still have problems after you rename them, then you may need to run
Rob Bovey's code cleaner

http://www.appspro.com

should be under the free downloads.

--
Regards,
Tom Ogilvy












- Show quoted text -

THANKS very, very much. Now everything works. I must have been
having a blond moment. You folks do not know how much I appreciate
the help you always provide. It is outstanding.
 

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

Top