UserForm.Show error

  • Thread starter Horatio J. Bilge, Jr.
  • Start date
H

Horatio J. Bilge, Jr.

I have a series of userforms set up so when I click on the "Next" button on
one, it closes, and the next userform opens. While I was tweaking some of the
code, the userform.show command stopped working. When I click on "Next" I get
Run-Time Error 438: Object doesn't support this property or method. When I
click on debug, the line UserForm3.Show is highlighted.

Here is my code:
Private Sub cmdNext_Click()
' Do some stuff with the info on the form
Unload Me
UserForm3.Show
End Sub
 
J

JLGWhiz

Try switching the unload and show lines like:

Private Sub cmdNext_Click()
' Do some stuff with the info on the form
UserForm3.Show
Unload Me
End Sub
 
H

Horatio J. Bilge, Jr.

Okay, I feel stupid.
After lots more testing, I tracked it down to 2 If statements in the
UserForm_Initialize sub on UserForm3. I commented out each line one at a
time, and found that there was one line in each If statement that it didn't
like. I took one of the lines out, and it worked fine. I put the line back
in, and it still worked fine. I compared the line I added back in with the
other bad line that I still had commented out, and discovered that I spelled
"Bold" with an "F" (fold).

It's working good now.
 
D

Dave Peterson

Maybe...

Private Sub cmdNext_Click()
' Do some stuff with the info on the form
me.hide
UserForm3.Show
Unload Me
End Sub

Make sure you didn't use UserForm3 as any other variable name, too.
 
J

JLGWhiz

Glad you found it Horatio. The reason I suggested switching the two lines
was on the theory that like closing a workbook containing the code before the
procedure has completed will stop the code, I thought it might apply to the
UF as well. Since I always unload my UF from the parent procedure, I had
never had the problem.
 
C

Chip Pearson

You could have saved yourself a great deal of time and effort by changing
the Error Handler setting in the Options dialog in the VBA editor from
"Break On Unhandled Errors" to "Break In Class Module". With the setting on
"Class Module", the debugger would have taken you directly to the offending
line of code rather than the Show statement, which loads the form into
memory (if necessary) and runs the Initialize event, and it is in the
Initialize event actually occurred.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
H

Horatio J. Bilge, Jr.

That's good to know. Thanks for the advice.


Chip Pearson said:
You could have saved yourself a great deal of time and effort by changing
the Error Handler setting in the Options dialog in the VBA editor from
"Break On Unhandled Errors" to "Break In Class Module". With the setting on
"Class Module", the debugger would have taken you directly to the offending
line of code rather than the Show statement, which loads the form into
memory (if necessary) and runs the Initialize event, and it is in the
Initialize event actually occurred.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 

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