Accessで垂直コントロールタブを使用できないため、私は偽のものを作成しています。Access 2016 VBA - コントロールのカスタムコレクションを作成し、コントロールの名前を手動で指定します。
page0
page1
...
pageN
:の形で、すべてのボタンは、それがタグとしてを参照だページを持っている
Private Sub updateBtnColor()
Dim currentPageIndexSZero As Long
Dim ctl As Control
currentPageIndexSZero = Me.tab1
For Each ctl In Me.Controls
If ctl.Tag = "page" & CStr(currentPageIndexSZero) Then
ctl.ForeColor = white
ElseIf InStr(1, ctl.Tag, "page", vbBinaryCompare) Then
ctl.ForeColor = black
End If
Next ctl
End Sub
:
私は(白に変更フォアカラー)を強調するために、現在のページをコードのこの作品を書きました
ループは基本的に現在のページをチェックし、適切なタグが付いたボタンを見つけて(正しく名前を付けたものとします)、そのテキストを強調表示します。
重いロードされたフォームや悪い習慣があるので、これは遅くなる可能性があるので、Controlsコレクション全体をループするのではなく、カスタムコレクションを作成することを考えました。
それをループ、何か私ができるので、私はこのような構造を作りたかった。その後、
Enum myButtons
button1 = Forms!myForm!button1
button2 = Forms!myForm!button2
button3 = Forms!myForm!button3
button4 = Forms!myForm!button4
End Enum
そして:
Public Sub updateBtnColor()
Dim curPageZ as Long
Dim button as Control
For Each button in myButtons
With button
If Right$(CStr(.Name, 1)) = curPageZ
.ForeColor = 16777215 ' White
Else ' No need for an additional ElseIf since I already know these are only the wanted buttons
.ForeColor = 0 ' Black
End If
End With
Next button
End Sub
などを作成するための最もエレガント/最速/最高/適切な方法は何ですか私のアイデアがそのようなものではない場合、そのような論理を作り出すためには?
ありがとうございます!
は、あなたがこのように意味http://www.fmsinc.com /microsoftaccess/controls/components/tabs/index.html – tahwos