コンボボックスに入れた値に基づいて、「hideme」とタグ付けされたすべてのフィールドを有効/無効にしたい。
comboxoxがyesの場合、フィールドを有効にする必要があり、フィールドを無効にする必要はありません。
これが実際に動作する例であり、これが私のコードですが、現時点では機能しません。
Private Sub myAction_AfterUpdate()
Dim frm As Form
Dim ctl As Control
Set frm = Forms!frmMyForm
For Each ctl In frm.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
If ctl.Tag = "hideMe" Then
If Me.myAction = yes Then
ctl.Enabled = True
End If
Else
ctl.Enabled = False
End If
End If
Next
End Sub
コントロールタグには、hideMe
タグとともに不要な文字列(下の画像を参照)が含まれていました。
下の画像はDebug.Print ctl.Tag
、クイックリファレンスのために即時ウィンドウに出力されています。
制御タグをとして設定し、hideMe
このコードを実行します。
Option Compare Database
Private Sub myAction_AfterUpdate()
Dim frm As Form
Dim ctl As Control
Set frm = Forms!frmMyForm
For Each ctl In frm.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
If ctl.Tag = "hideMe" Then
If Me.myAction = "yes" Then
ctl.Enabled = True
Else
ctl.Enabled = False
End If
End If
End If
Next
End Sub
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加