ShortcutMenuBar error 438

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
 
B

Brendan Reynolds

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
 

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