Userform Error 91 and 438

B

Bishop

I have the following code:

Option Explicit

Sub ControlForms(varCode)

If Chr(varCode) = "A" Then
Unload AddOrFind
AddTitle.Show
ElseIf Chr(varCode) = "F" Then
Unload AddOrFind
GetTitle.Show
ElseIf Chr(varCode) = "V" Then
Unload AddOrFind
Summary.Show
End If

End Sub

Private Sub AddButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
ControlForms KeyCode
End Sub

Private Sub FindButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
ControlForms KeyCode
End Sub

Private Sub SummaryButton_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
ControlForms KeyCode
End Sub

When I press 'a' I get the desired result (AddOrFind userform pops up).
When I press 'f' I get error 91 (Object variable or With Block variable not
set) at GetTitle.Show. When I press 'v' I get error 438 (Object doesn't
support this property or method) at Summary.Show. I have verified both
userforms are under the correct name and the code compiles. What's the
problem?
 
P

Per Jessen

Hi

Summary is a used property in excel, so you shouldn't use it as a
userform name. Change the userform name and it should work.

I am not sure about the GetTitle userform (it is at least not used in
excel 2000), but it won't hurt to change this name too.

Hopes this helps.
....
Per
 
J

JLGWhiz

Sometimes the problem is in the UserForm_Initialize code, but the debug
highlight goes back to the call line. If you have such code, check it for a
variable that is a rage object without the Set command. So I suspect the
problem is in code withing UserForms GetTitle and Summary.
 

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