ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Userform Error 91 and 438 (https://www.excelbanter.com/excel-programming/430550-userform-error-91-438-a.html)

Bishop

Userform Error 91 and 438
 

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?

Per Jessen[_2_]

Userform Error 91 and 438
 
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

On 30 Jun., 21:36, Bishop wrote:
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?



JLGWhiz[_2_]

Userform Error 91 and 438
 

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.


"Bishop" wrote in message
...
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?





All times are GMT +1. The time now is 07:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com