Color scheme: Riviera
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » WKL Forms Object Library API reference » WklButtonEdit

WklButtonEdit

WklButtonEdit class

Signature

Dim myWklButtonEdit As WklButtonEdit
Set myWklButtonEdit = Me!ControlName.Object

Summary

A text box with a button on its right, bound like an Access text box - for a value that comes from a dialog or a check: look up a Windows account, test a connection, change a secret.

Parameters

None

Remarks

Bind it through Control Source like a text box: Access writes the field into Value on every record change. The first keystroke of the user asks Access whether the field may be edited; a locked control (Locked) or a form without edits (AllowEdits = False) refuses, and the key is dropped. Every change of the text marks the record as changed; Access writes the text into the field when the record is saved at the latest, so read the control (Value, Text) rather than the field while the user types. An empty text is Null. Esc puts back the value the control had before the user's first change; a second Esc goes to Access.

The button raises ButtonClick. A click, F4, Alt+Down and a screen reader's Invoke press it; it is no tab stop, as the builder button [...] of the property sheet, and the focus stays in the text. In ButtonClick set Value to the result of your dialog: a value set by code is shown but does not mark the record as changed - set the field as well (Me!Account = result) when the record shall be saved with it.

TextEditable = False shows the text but lets only code change it, for example a secret that the button replaces through a dialog of its own. PasswordMask shows the system password character; screen readers then hear a password field.

Enabled, Locked, Visible, TabStop and the tooltip (ControlTipText) are Access's own properties of the control. A disabled control is drawn as a picture and takes no keys.

An ActiveX control: inserted into a form in design view (Form Design › Controls › ActiveX Controls); reports are not supported. VBA reaches it through the Object property of the control, where ControlName is the name of the control on the form.

MemberKindSummary
`Value`PropertyGets or sets the value: the text, or Null for an empty text.
`Caption`PropertyGets or sets the name screen readers hear for the text field.
`ButtonCaption`PropertyGets or sets the caption of the button.
`ButtonText`PropertyGets or sets the name and tooltip of the button.
`TextEditable`PropertyGets or sets whether the user can type into the text.
`PasswordMask`PropertyGets or sets whether the characters are shown as the system password character.
`MaxLength`PropertyGets or sets the highest number of characters of the text the user enters.
`BackColor`PropertyGets or sets the background color of the text.
`ForeColor`PropertyGets or sets the color of the text.
`FontName`PropertyGets or sets the font of text and button.
`FontSize`PropertyGets or sets the size of the font.
`Text`PropertyReturns the text shown, also while the user types.
`ClickButton`MethodPresses the button as the user would: raises ButtonClick.
`ColorScheme`PropertyGets or sets the color scheme the control draws in.
EventSummary
`ButtonClick`Occurs when the button is pressed: a click, F4 or Alt+Down in the text, a screen reader's Invoke, or ClickButton.
`Change`Occurs when the user changed the text, after the change was reported to Access.

Code example

' Form module: the button looks up a Windows account and puts it into the field.
Private Sub btnAccount_ButtonClick()
    Dim account As String
    account = InputBox("Windows-Konto (DOMAIN\Name):", "Konto suchen", Nz(Me!Account, ""))
    If Len(account) = 0 Then Exit Sub
    Me!Account = account                         ' the field: the record is saved with it
    Me!btnAccount.Object.Value = account         ' the control: shows it at once
End Sub

Inheritance

None

Value property

Signature

Property Get Value() As Variant
Property Let Value(RHS As Variant)

Summary

Gets or sets the value: the text, or Null for an empty text.

Parameters

None

Property value: Variant – The value. Access writes the field of ControlSource into it on every record change; code may set it. Neither marks the record as changed.

Remarks

A value set by code or by Access replaces the text and ends an edit of the user (Esc then has nothing to undo). Read Value rather than the bound field while the user types: Access reads the control into the field when the record is saved.

Read/write.

Code example

None

Inheritance

Declared by WklButtonEdit.

Caption property

Signature

Property Get Caption() As String
Property Let Caption(RHS As String)

Summary

Gets or sets the name screen readers hear for the text field.

Parameters

None

Property value: String – The name; empty (default) uses the control's name.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklButtonEdit.

ButtonCaption property

Signature

Property Get ButtonCaption() As String
Property Let ButtonCaption(RHS As String)

Summary

Gets or sets the caption of the button.

Parameters

None

Property value: String – A short text, for example “…” (default) or “Change…”; an empty text raises wkeInvalidValue.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklButtonEdit.

ButtonText property

Signature

Property Get ButtonText() As String
Property Let ButtonText(RHS As String)

Summary

Gets or sets the name and tooltip of the button.

Parameters

None

Property value: String – The text screen readers hear and the tooltip shows, for example “Konto suchen”; default “Durchsuchen”.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklButtonEdit.

TextEditable property

Signature

Property Get TextEditable() As Boolean
Property Let TextEditable(RHS As Boolean)

Summary

Gets or sets whether the user can type into the text.

Parameters

None

Property value: Boolean – True (default) the user types; False the text is shown and only code and the button's procedure change it.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklButtonEdit.

PasswordMask property

Signature

Property Get PasswordMask() As Boolean
Property Let PasswordMask(RHS As Boolean)

Summary

Gets or sets whether the characters are shown as the system password character.

Parameters

None

Property value: Boolean – True shows the password character; False (default) shows the text.

Remarks

The text can still be read by code (Value, Text); the mask hides it on the screen only. Copying from a masked field is not possible, as in any Windows password field.

Read/write.

Code example

None

Inheritance

Declared by WklButtonEdit.

MaxLength property

Signature

Property Get MaxLength() As Long
Property Let MaxLength(RHS As Long)

Summary

Gets or sets the highest number of characters of the text the user enters.

Parameters

None

Property value: Long – The number; 0 (default) for no limit. A negative number raises wkeInvalidValue.

Remarks

Applies to typing, pasting and a text a screen reader sets (it is cut); Value set by code is not cut.

Read/write.

Code example

None

Inheritance

Declared by WklButtonEdit.

BackColor property

Signature

Property Get BackColor() As OLE_COLOR
Property Let BackColor(RHS As OLE_COLOR)

Summary

Gets or sets the background color of the text.

Parameters

None

Property value: OLE_COLOR – An OLE color; default the window background of Windows.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklButtonEdit.

ForeColor property

Signature

Property Get ForeColor() As OLE_COLOR
Property Let ForeColor(RHS As OLE_COLOR)

Summary

Gets or sets the color of the text.

Parameters

None

Property value: OLE_COLOR – An OLE color; default the window text of Windows.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklButtonEdit.

FontName property

Signature

Property Get FontName() As String
Property Let FontName(RHS As String)

Summary

Gets or sets the font of text and button.

Parameters

None

Property value: String – The font name; default Segoe UI. An empty name raises wkeInvalidValue.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklButtonEdit.

FontSize property

Signature

Property Get FontSize() As Long
Property Let FontSize(RHS As Long)

Summary

Gets or sets the size of the font.

Parameters

None

Property value: Long – Points, 6 to 72; default 9. Another size raises wkeInvalidValue.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklButtonEdit.

Text property

Signature

Property Get Text() As String

Summary

Returns the text shown, also while the user types.

Parameters

None

Property value: String – The text; an empty text for Null.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklButtonEdit.

ClickButton method

Signature

Sub ClickButton()

Summary

Presses the button as the user would: raises ButtonClick.

Parameters

None

Remarks

Only in form view; in design view it raises wkeNotAvailable.

Code example

None

Inheritance

Declared by WklButtonEdit.

ColorScheme property

Signature

Property Get ColorScheme() As WklColorScheme
Property Let ColorScheme(RHS As WklColorScheme)

Summary

Gets or sets the color scheme the control draws in.

Parameters

None

Property value: `WklColorScheme` – wcoAutomatic (default), wcoLight, wcoDark or wcoHighContrast.

Remarks

wcoAutomatic follows, in this order, Windows high contrast mode, then the color set of the database design (Access: Design › Themes or Colors), and draws light when the database has no design or the control is on an Excel or Word UserForm. Office's own design setting and the Windows app mode are not followed: a database looks the same on every PC. In high contrast mode the control always uses the system colors. The scheme colors background and text (while BackColor and ForeColor keep the system defaults), the frame and the button; a BackColor you set wins over the scheme. Every text keeps a contrast of at least 4.5:1. The control reads the database design after it is first drawn, never while Access draws the form, and again when the form opens anew. The value is saved with the form.

Read/write.

Code example

None

Inheritance

Declared by WklButtonEdit.

ButtonClick event

Signature

Event ButtonClick()

Summary

Occurs when the button is pressed: a click, F4 or Alt+Down in the text, a screen reader's Invoke, or ClickButton.

Parameters

None

Remarks

In a form module: Private Sub <ControlName>_ButtonClick(). The event comes after the mouse or key handling has ended, so the procedure may open a dialog.

In a form module: Private Sub <ControlName>_ButtonClick(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklButtonEdit.

Change event

Signature

Event Change()

Summary

Occurs when the user changed the text, after the change was reported to Access.

Parameters

None

Remarks

Occurs once per change - a typed character, a deletion, a paste - not for a value set by code or by Access.

In a form module: Private Sub <ControlName>_Change(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklButtonEdit.

en/wiki/msaccess/comctl/api-reference/wklbuttonedit.txt · Last modified: by Wolfgang van der Stille