Rubrik: Access | VB-Versionen: VBA | 02.08.01 |
Aktive Eingabefelder Stellen Sie die aktiven Eingabe-, Listen-, Kombinationsfelder, Kontrollkästchen, Optionsgruppen und Befehlsschaltflächen bei Aktivierung farbig dar. | ||
Autor: Microsys Kramer | Bewertung: | Views: 28.243 |
www.access-paradies.de | System: Win9x, WinNT, Win2k, WinXP, Win7, Win8, Win10, Win11 | Beispielprojekt auf CD |
Programmbeispiel für aktive Eingabefelder.
Stellen Sie die aktiven Eingabe-, Listen-, Kombinationsfelder, Kontrollkästchen, Optionsgruppen und Befehlsschaltflächen bei Aktivierung farbig dar.
Immer, wenn ein Feld mit dem Cursor angesprungen wird, kann dieses farblich dargestellt werden. Somit sieht der Anwender sofort, welches Feld bzw. welche Schaltfläche ist aktiv.
An dieser Stelle unser Dank an Herrn Matthias Kaskel, der sich die Mühe machte und dieses Beispiel überarbeitet hat.
Erstellen Sie ein neues Modul und fügen Sie nachfolgenden Code ein:
Option Compare Database Option Explicit Public Feldfarbe As Long Public Textfarbe As Long Public Kontrollkaestchenfarbe As Long Public Kontrollbezfeld As String Private Const conAktivesKontrollfeldFarbe = 8388608 Private Const conAktivesTextfeldFarbe = 8454143 Public Function aktives_Eingabefeld(Status As Boolean) On Error GoTo Err_aktives_Eingabefeld Dim Steuerelement1 As Control Set Steuerelement1 = Screen.ActiveControl With Steuerelement1 If Status Then Feldfarbe = .BackColor Textfarbe = .ForeColor .ForeColor = 0 .BackColor = conAktivesTextfeldFarbe Else .ForeColor = Textfarbe .BackColor = Feldfarbe End If End With Exit_aktives_Eingabefeld: Exit Function Err_aktives_Eingabefeld: Select Case Err Case 0 Resume Next Case Else Resume Exit_aktives_Eingabefeld End Select Resume 0 End Function Public Function aktive_Schaltfläche(Status As Boolean) On Error GoTo Err_aktive_Schaltfläche Dim Steuerelement1 As Control Set Steuerelement1 = Screen.ActiveForm.ActiveControl With Steuerelement1 If Status Then Kontrollkaestchenfarbe = .ForeColor .ForeColor = conAktivesKontrollfeldFarbe Else .ForeColor = Kontrollkaestchenfarbe End If End With Exit_aktive_Schaltfläche: Exit Function Err_aktive_Schaltfläche: Select Case Err Case 0 Resume Next Case Else Resume Exit_aktive_Schaltfläche End Select Resume 0 End Function Public Function aktives_Kontrollkästchen(Status As Boolean) On Error GoTo Err_aktives_Kontrollkästchen Dim Steuerelement1 As Control With Screen Kontrollbezfeld = .ActiveForm.ActiveControl.Name & _ "_Text" Set Steuerelement1 = .ActiveForm(Kontrollbezfeld) End With With Steuerelement1 If Status Then Kontrollkaestchenfarbe = .ForeColor .ForeColor = conAktivesKontrollfeldFarbe Else .ForeColor = Kontrollkaestchenfarbe End If End With Exit_aktives_Kontrollkästchen: Exit Function Err_aktives_Kontrollkästchen: Select Case Err Case 0 Resume Next Case Else Resume Exit_aktives_Kontrollkästchen End Select Resume 0 End Function