ShortcutMenuBar error 438

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

With the following code I get a runtime error 438....Object doesn't support
this property or method. If code gets hung up on the first "If" statement
below.......Can you tell me what I am doing wrong? Thanks, Chace
For Each ctl In Me
With ctl
If .ShortcutMenuBar = "num" Then
DataType = 1
Else
If .ShortcutMenuBar = "x" Then
DataType = 2
End If
End If

Select Case DataType
Case 1
'Case 1 stuff here
Case 2
'Case 2 stuff here
End Select
End With
Next ctl
 
Some types of control, such as attached labels, lines, and rectangles, don't
have a ShortCutMenuBar property. You could trap the error and continue, or
test the ControlType property first ...

Dim ctl As Control
Dim lngType As Long

For Each ctl In Me.Controls
lngType = ctl.ControlType
Select Case lngType
Case acTextBox, acComboBox, acListBox, acCommandButton
Debug.Print ctl.ShortcutMenuBar
Case Else
'do nothing
End Select
Next ctl
 
Back
Top