Google
 
Diesen Blog abonnieren

Beliebte Posts

Donnerstag, 29. Oktober 2009

Access für Fortgeschrittene: Feldeigenschaften in Formularen steuern

Ist die Eingabe in einem Access Formular abgeschlossen, so will man häufig einen Teil oder alle Felder sperren. In VBA hat man mit Controls beinahe unbeschränkte Manipulationsmöglichkeiten.

Beispiel 1, Sperren aller Felder ausser den Checkboxen:

Dim ctl As Control

On Error Resume Next

For Each ctl In Me

'alle Checkboxen bleiben zugreifbar
If ctl.Properties("ControlType") <> 106 Then

'fldFullAccess ist eine Checkbox im Formular
ctl.Locked = Not Me!fldFullAccess
ctl.editable = Me!fldFullAccess

End If

'Weil es so einfach ist, schalten wir gleich noch den Button für den FileDialog sichtbar oder unsichtbar

If ctl.Properties("ControlType") = 104 Then

ctl.Properties("Visible") = Me!fldFullAccess

End If

Next

Beispiel 2, Sperren aller Felder unterhalb der y-Koordinate 590

Dim ctl As Control

On Error Resume Next

For Each ctl In Me

'alle Felder unterhalb y=590 werden gesperrt
If ctl.Properties("Top") > 590 Then

'fldFullAccess ist eine Checkbox im Formular
ctl.Locked = Not Me!fldFullAccess

End If


Next

Hier eine Auflistung der Control Konstanten inkl. zugehöriger Wert:

Constant Value
acBoundObjectFrame 108
acCheckBox 106
acComboBox 111
acCommandButton 104
acCustomControl 119
acImage 103
acLabel 100
acLine 102
acListBox 110
acObjectFrame 114
acOptionButton 105
acOptionGroup 107
acPage 124
acPageBreak 118
acRectangle 101
acSubform 112
acTabCtl 123
acTextBox 109
acToggleButton 122

und hier die möglichen Funktionen an einem Beispiel einer Textbox:

EventProcPrefix = ID_Anf
Name = ID_Anf
ControlType = 109
ControlSource = ID_Anf
Format = General Number
DecimalPlaces = 255
Visible = Wahr
TextFormat = 0
DatasheetCaption =
ShowDatePicker = 1
Width = 975
Height = 315
Top = 600
Left = 8730
BackStyle = 1
BackColor = 16777215
BorderStyle = 1
OldBorderStyle = 1
BorderLineStyle = 0
BorderWidth = 3
BorderColor = 52479
SpecialEffect = 4
ScrollBars = 0
TextFontCharSet = 0
FontName = Arial
FontSize = 9
TextAlign = 0
FontWeight = 400
FontUnderline = Falsch
FontItalic = Falsch
FontBold = 0
ForeColor = 0
LineSpacing = 0
IsHyperlink = Falsch
DisplayAsHyperlink = 0
GridlineStyleTop = 0
GridlineStyleBottom = 0
GridlineStyleLeft = 0
GridlineStyleRight = 0
GridlineColor = 0
GridlineWidthTop = 1
GridlineWidthBottom = 1
GridlineWidthLeft = 1
GridlineWidthRight = 1
TopMargin = 0
BottomMargin = 0
LeftMargin = 0
RightMargin = 0
TopPadding = 30
BottomPadding = 30
LeftPadding = 30
RightPadding = 30
HorizontalAnchor = 0
VerticalAnchor = 0
CanGrow = Falsch
CanShrink = Falsch
DisplayWhen = 0
ReadingOrder = 0
ScrollBarAlign = 0
NumeralShapes = 0
KeyboardLanguage = 0
InputMask =
DefaultValue =
ValidationRule =
ValidationText =
FilterLookup = 1
Enabled = Wahr
Locked = Wahr
OnClick = [Event Procedure]
OnClickEmMacro =
BeforeUpdate =
BeforeUpdateEmMacro =
AfterUpdate =
AfterUpdateEmMacro =
OnDirty =
OnDirtyEmMacro =
OnChange =
OnChangeEmMacro =
OnGotFocus =
OnGotFocusEmMacro =
OnLostFocus =
OnLostFocusEmMacro =
OnDblClick =
OnDblClickEmMacro =
OnMouseDown =
OnMouseDownEmMacro =
OnMouseUp =
OnMouseUpEmMacro =
OnMouseMove =
OnMouseMoveEmMacro =
OnKeyDown =
OnKeyDownEmMacro =
OnKeyUp =
OnKeyUpEmMacro =
OnKeyPress =
OnKeyPressEmMacro =
OnEnter =
OnEnterEmMacro =
OnExit =
OnExitEmMacro =
OnUndo =
OnUndoEmMacro =
EnterKeyBehavior = Falsch
ControlTipText =
TabIndex = 6
TabStop = Wahr
StatusBarText =
ShortcutMenuBar =
HelpContextId = 0
AutoTab = Falsch
Vertical = Falsch
AllowAutoCorrect = Wahr
IMEHold = Falsch
IMEMode = 0
IMESentenceMode = 3
SmartTags =
Tag =
ConditionalFormat =
FuriganaControl =
ColumnWidth = 1245
ColumnOrder = 0
ColumnHidden = Falsch
Section = 0
AggregateType = -1
Layout = 0
LayoutID = 0

Keine Kommentare: