誕生日にもらった意外なもの

フォーム上のコントロールを取得する時に、
「テキストボックスかコンボボックスなら」としたいのですが、VBAコードがわかりません。

************************************************************
Sub Sample()
Dim myCtrl As Control
Dim myForm As String

myForm = "フォーム1"

For Each myCtrl In Forms(myForm).Controls
If myCtrlのタイプがテキストボックス Or コンボボックス Then
Debug.Print myCtrl.Name
End If
Next

End Sub
************************************************************

に修正していただけますか?

ControlType プロパティを使うと思うのですが、使い方がわかりません。
ご回答よろしくお願いします。

A 回答 (1件)

この辺をよく読んでみて


http://oshiete.goo.ne.jp/qa/7685952.html
考える。
    • good
    • 0
この回答へのお礼

For Each ctl In Form_F上.Controls
If (ctl.ControlType = acTextBox) Or (ctl.ControlType = acComboBox) Then
Debug.Print ctl.Name
End If
Next ctl
で、うまくいきました。ありがとうございました。

お礼日時:2012/10/02 21:20

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!