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

WklPropertyGrid

WklPropertyGrid class

Signature

Dim myWklPropertyGrid As WklPropertyGrid
Set myWklPropertyGrid = Me!ControlName.Object

Summary

One record as lines “caption | value”, the fields grouped into categories that fold away - like the property window of Visual Studio - with the editors, formats, lookups and rules of WklGrid.

Parameters

None

Remarks

Two modes. Without RecordSource the grid shows the current record of the Access form it sits on: every value is read like Me!Field, a changed value goes into the form's record, which becomes dirty and is saved by Access as any typing on the form - when the record is left or saved, with the form's own validation. The grid follows the form's records by itself (it compares the record shown with the form's current one a few times per second; no form module is needed). With RecordSource and LinkMasterFields it is the detail of a WklGrid or WklTreeList on the same form - LinkMasterFields = "Grid1" follows the record selected in Grid1, whose own source may be a pass-through query - and writes each field into its own record source when the user leaves the field (AutoSave). WklGrid selects no record when the form opens, so the detail stays empty until the first selection.

The rows are WklColumn objects (Rows): field, caption, editor, format, lookup, read-only state and rules exactly as for a grid column; the column's Band is the row's category. Without rows every field of the source is a row, with an editor for its type. Fields without category come first; the categories follow in the order of their first field, each with a header that folds its fields away (click, or Left/Right/Enter on the header).

Which fields can be edited, the data source tells without any setting: a pass-through or union query cannot be written, calculated fields of a query, AutoNumber fields and columns a linked ODBC table reports as not updatable are read-only; in form mode the form's AllowEdits applies too. Read-only rows have a gray caption and open no editor; FieldEditable tells the state. With a recordset handed over by code nothing is asked: every field counts as editable and a change goes into that recordset, which a static or read-only ADO recordset keeps in memory without an error - set ReadOnly on the rows in that mode. Rows name fields: empty them with Rows.Clear before a source without those fields, which the grid refuses otherwise (wkeSourceError).

Keyboard as in the Visual Studio property window: Up and Down go from line to line (category headers included), Page Up/Down by a page, Ctrl+Home/End to the first and last line; Tab and Shift+Tab go from value to value; F2 or typing edits, Enter saves, Esc discards; on a category header Left folds, Right unfolds, Enter toggles; Left on a field goes to its category. Screen readers hear each field by its caption, with its value in the Value pattern.

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
`Key`PropertyGets the key of the record shown (the value of KeyField); Null when no record is shown.
`RecordSource`PropertyGets or sets the table, query or SQL statement with the record shown; empty: the record of the form the grid sits on.
`KeyField`PropertyGets or sets the field with the unique key of a record.
`BackColor`PropertyGets or sets the background color.
`ForeColor`PropertyGets or sets the text color.
`FontName`PropertyGets or sets the font name.
`FontSize`PropertyGets or sets the font size in points.
`Recordset`PropertyGets or sets the DAO or ADO recordset the records were loaded from.
`Requery`MethodReads the record source again.
`AutoSave`PropertyGets or sets whether changes are written into the record source right away.
`EventProcedures`PropertyLists the events that have an event procedure in the form module.
`LinkChildFields`PropertyGets or sets the fields that link the records to a master record, as on an Access subform.
`LinkMasterFields`PropertyGets or sets the fields or controls of the master that hold the values for LinkChildFields.
`MasterValue`PropertyGets or sets the value Access writes into the control on every record change of the form when ControlSource is set.
`MasterValues`PropertyGets or sets the master values the records are limited to.
`MasterRecordset`PropertyGets or sets a DAO or ADO recordset whose current record is the master.
`SyncMaster`MethodReads the master values again and reloads the records when they changed.
`MasterFilterMode`PropertyGets or sets how a linked grid selects the records of the master record.
`Rows`PropertyGets the rows: one WklColumn per field, in the order shown.
`FormatRules`PropertyReturns the conditional formatting rules.
`RowHeight`PropertyGets or sets the height of a line in twips; 0 (default): from the font.
`AllowEditing`PropertyGets or sets whether values can be edited (default True); what the data source cannot write stays read-only either way (FieldEditable).
`FocusedField`PropertyGets or sets the field of the line with the focus.
`FormatEvents`PropertyGets or sets whether FieldFormat is raised while each value is drawn (default False).
`ValidateMode`PropertyGets or sets when the rules of the columns are checked.
`ClearErrors`MethodRemoves the errors of a record, or every error.
`ErrorCount`PropertyGets the number of errors shown.
`GoToFirstError`MethodSelects the record of the first error and shows its cell.
`ErrorSummary`PropertyGets the summary of the errors as the error bar shows it.
`Value`PropertyGets or sets the value of a field of the record shown.
`LabelWidth`PropertyGets or sets the width of the caption column in twips (default 2160 = 1.5 inches).
`CategoryCollapsed`PropertyGets or sets whether the fields of a category are folded away.
`SetError`MethodMarks a field as wrong, as a rule would, or clears its mark.
`ErrorText`PropertyGets the message of a field's error; empty without error.
`FieldEditable`PropertyGets whether the user could edit a field.
`ColorScheme`PropertyGets or sets the color scheme the control draws in.
`EditOnClick`PropertyGets or sets whether a single click into an editable cell opens its editor.
EventSummary
`AfterRequery`Occurs after the records were loaded again.
`DataError`Occurs when loading or saving fails.
`KeyDown`Occurs when a key is pressed while the control has the focus.
`KeyPress`Occurs when a character is typed.
`KeyUp`Occurs when a key is released.
`BeforeUpdate`Occurs before each write into the record source caused by an action of the user.
`AfterUpdate`Occurs after each write into the record source caused by an action of the user.
`FieldClick`Occurs when the user clicks a value.
`FieldDblClick`Occurs when the user double-clicks a value.
`BeforeFieldEdit`Occurs before an editor opens for a value.
`ValidateField`Occurs after the user entered a value, before it is written.
`AfterFieldUpdate`Occurs after a value was written.
`FieldFormat`Occurs while a value is drawn, when FormatEvents is on; the procedure can change its colors and font.
`FocusedFieldChange`Occurs when the focus moved to another field.
`BeforeMasterChange`Occurs before the grid changes to the records of another master record.
`AfterMasterChange`Occurs after the grid was loaded with the records of another master record.
`ValidationChange`Occurs when the errors shown have changed.

Code example

' The detail of the customer list: Props1 shows the customer selected in Grid1.
Private Sub Form_Load()
    With Me!Props1.Object
        .RecordSource = "tblCustomers"
        .KeyField = "ID"
        .LinkMasterFields = "Grid1"
        .LinkChildFields = "ID"
        .Rows.Clear
        .Rows.Add "Name", "Name"
        .Rows.Add "Ort", "Ort", "Adresse"
        .Rows.Add "Aktiv", "Aktiv", "Status"
    End With
End Sub

Inheritance

None

Key property

Signature

Property Get Key() As Variant

Summary

Gets the key of the record shown (the value of KeyField); Null when no record is shown.

Parameters

None

Property value: Variant

Remarks

In form mode without KeyField the record's position in the form (CurrentRecord), “neu” on a new record.

Default member: it can be left out, as in myWklPropertyGrid(...) for myWklPropertyGrid.Key(...). Read-only.

Code example

None

Inheritance

Declared by WklPropertyGrid.

RecordSource property

Signature

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

Summary

Gets or sets the table, query or SQL statement with the record shown; empty: the record of the form the grid sits on.

Parameters

None

Property value: String

Remarks

With LinkMasterFields the grid shows the record linked to the master's current record. Without a record source it follows its form's current record and writes into it (form mode, see the class remarks). Setting it in form view reads the record again.

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

KeyField property

Signature

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

Summary

Gets or sets the field with the unique key of a record.

Parameters

None

Property value: String – A field name of the record source, or several separated by semicolons for a composite key (OrderID;LineNo).

Remarks

A duplicate key raises wkeDuplicateKey when the grid loads. With a composite key, keys are arrays in VBA (Array(4711, 2)).

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

BackColor property

Signature

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

Summary

Gets or sets the background color.

Parameters

None

Property value: OLE_COLOR – A color number as in Access; system colors from &H80000000 on. Default: the Windows window color.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

ForeColor property

Signature

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

Summary

Gets or sets the text color.

Parameters

None

Property value: OLE_COLOR – A color number as in Access; system colors from &H80000000 on. Default: the Windows window text color.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

FontName property

Signature

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

Summary

Gets or sets the font name.

Parameters

None

Property value: String – The name of an installed font. Default: Segoe UI.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

FontSize property

Signature

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

Summary

Gets or sets the font size in points.

Parameters

None

Property value: Long – The size in points. Default: 9.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

Recordset property

Signature

Property Get Recordset() As Object
Property Set Recordset(RHS As Object)

Summary

Gets or sets the DAO or ADO recordset the records were loaded from.

Parameters

None

Property value: Object – The recordset, or Nothing when the grid is bound through RecordSource.

Remarks

Assign with Set: all records are loaded at once from the recordset. A grid loaded this way does not write back with AutoSave and shows no row for a new record, because it has no record source to write to.

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

Requery method

Signature

Sub Requery()

Summary

Reads the record source again.

Parameters

None

Remarks

The selection and the expanded groups are kept as far as they still exist. Raises AfterRequery.

Code example

None

Inheritance

Declared by WklPropertyGrid.

AutoSave property

Signature

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

Summary

Gets or sets whether changes are written into the record source right away.

Parameters

None

Property value: Boolean – True (default) to write every change; False to change only the display.

Remarks

Each operation is written in one transaction; BeforeUpdate can cancel it and roll back what was already written. A grid loaded from a Recordset never writes.

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

EventProcedures property

Signature

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

Summary

Lists the events that have an event procedure in the form module.

Parameters

None

Property value: String – The event names, separated by semicolons. Writing is ignored.

Remarks

Access never lists the events of an ActiveX control on the property sheet's Event tab. This row of the Other tab is the way to them: its [...] button opens the Events page, which creates or opens the event procedures.

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

LinkChildFields property

Signature

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

Summary

Gets or sets the fields that link the records to a master record, as on an Access subform.

Parameters

None

Property value: String – Field names of the record source, separated by semicolons; empty (default) for a grid without master.

Remarks

With LinkChildFields set, the grid shows only the records whose link fields equal the master values (see LinkMasterFields, MasterValues and MasterRecordset). Without a master record - a new or empty master - the grid is empty and new records are refused. New records, also those of the row for a new record, get the master values in their link fields. The value is saved with the form.

Read/write.

Code example

With Me!Grid1.Object
    .LinkChildFields = "OrderID"
    .LinkMasterFields = "ID"
End With

Inheritance

Declared by WklPropertyGrid.

LinkMasterFields property

Signature

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

Summary

Gets or sets the fields or controls of the master that hold the values for LinkChildFields.

Parameters

None

Property value: String – Names in the same order as LinkChildFields, separated by semicolons.

Remarks

The master is the form the control sits on, unless MasterRecordset or MasterValues is set. A name is looked up as a field of the form's recordset first and as a control of the form second, as LinkMasterFields of an Access subform. In form view the control checks the master record on idle (every 250 ms) and reloads when it changed; with ControlSource set, Access reports each change at once through MasterValue.

A name can also name another WKL control of the same form (WklGrid, WklTreeList, WklTreeView, WklGantt) as the master. Only the form the control sits on is searched: a control inside a subform cannot name a control of the main form; use MasterValues or MasterRecordset from code for that case. Grid1 stands for its key (every part of a composite key), Grid1.KundeID for a field of its selected record - the key, a column, or any other field of its record source. The control then follows the selection of that control without code: at once for a change made by code, after a short pause while the user moves through the records with the keyboard. With nothing selected there, or a group row, the control shows no records. Names of both kinds can be mixed. In design view with LivePreview, the first record of the master control's record source is the master.

The other way round, an Access subform follows a WKL control when its LinkMasterFields names the control (Grid1) and its LinkChildFields the field that holds the key: Access reads the selected key through the control's Value, and the control requeries such subforms when its selection changes, because Access does not do it by itself.

The value is saved with the form.

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

MasterValue property

Signature

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

Summary

Gets or sets the value Access writes into the control on every record change of the form when ControlSource is set.

Parameters

None

Property value: Variant – The current value of the control's ControlSource.

Remarks

MasterValue is the bindable default property of the control for Access' data binding: set the control's ControlSource (property sheet, tab Data) to a link field such as ID, or to an expression over several fields, and Access writes the current value on every record change - also for filters and new records. The value is only the trigger: the master values are read from LinkMasterFields. Without ControlSource, the idle check does the same with a delay of up to 250 ms.

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

MasterValues property

Signature

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

Summary

Gets or sets the master values the records are limited to.

Parameters

None

Property value: Variant – A value for one link field, or an array with one value per link field; Null when there is no master record.

Remarks

Reading returns the current master values, wherever they come from. Setting a value takes it from code and ignores the form and MasterRecordset until MasterValues is set to Null; this works in any container, also on Excel, Word and Outlook UserForms, which have no form recordset. Setting from code raises no events.

Read/write.

Code example

UserForm1.List1.MasterValues = Array("A", 4711)   ' two link fields, on an Excel UserForm

Inheritance

Declared by WklPropertyGrid.

MasterRecordset property

Signature

Property Get MasterRecordset() As Object
Property Set MasterRecordset(RHS As Object)

Summary

Gets or sets a DAO or ADO recordset whose current record is the master.

Parameters

None

Property value: Object – The recordset, or Nothing to use the form again.

Remarks

Assign with Set. The control reads LinkMasterFields from the current record of the recordset, for example of another subform's recordset or a combo box's. In form view it checks the record on idle; SyncMaster reads it at once. A field that the recordset does not have raises wkeInvalidValue.

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

SyncMaster method

Signature

Sub SyncMaster()

Summary

Reads the master values again and reloads the records when they changed.

Parameters

None

Remarks

Needed only when the master changes outside form view or must take effect at once, for example after moving MasterRecordset by code. Raises no events.

Code example

None

Inheritance

Declared by WklPropertyGrid.

MasterFilterMode property

Signature

Property Get MasterFilterMode() As WklMasterFilterMode
Property Let MasterFilterMode(RHS As WklMasterFilterMode)

Summary

Gets or sets how a linked grid selects the records of the master record.

Parameters

None

Property value: `WklMasterFilterMode` – wmfSource (default) to read the records of each master record through a WHERE condition on the record source; wmfLocal to read the record source once and filter it in memory.

Remarks

Applies only with LinkChildFields set. wmfLocal is meant for sources that Access can only wrap, such as a pass-through query or a slow linked table: with wmfSource every master change runs the whole query again. With wmfLocal the grid reads all records once, together with the link fields, and each master change only filters them; Requery and every change the grid writes read the source again. The value is saved with the form.

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

Rows property

Signature

Property Get Rows() As WklColumns

Summary

Gets the rows: one WklColumn per field, in the order shown.

Parameters

None

Property value: `WklColumns`

Remarks

Rows.Add Field, Caption, Category appends a row; the third argument is the column's Band, here the category. Without rows every field of the source is a row. Width, footer summary, line in band and the tree column of a grid column have no meaning here.

Read-only.

Code example

None

Inheritance

Declared by WklPropertyGrid.

FormatRules property

Signature

Property Get FormatRules() As WklFormatRules

Summary

Returns the conditional formatting rules.

Parameters

None

Property value: `WklFormatRules` – The `WklFormatRules` collection.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklPropertyGrid.

RowHeight property

Signature

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

Summary

Gets or sets the height of a line in twips; 0 (default): from the font.

Parameters

None

Property value: Long

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

AllowEditing property

Signature

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

Summary

Gets or sets whether values can be edited (default True); what the data source cannot write stays read-only either way (FieldEditable).

Parameters

None

Property value: Boolean

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

FocusedField property

Signature

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

Summary

Gets or sets the field of the line with the focus.

Parameters

None

Property value: String

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

FormatEvents property

Signature

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

Summary

Gets or sets whether FieldFormat is raised while each value is drawn (default False).

Parameters

None

Property value: Boolean

Remarks

Every call to VBA costs about 3 ms per value shown; switch it on only when the form handles FieldFormat.

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

ValidateMode property

Signature

Property Get ValidateMode() As WklValidateMode
Property Let ValidateMode(RHS As WklValidateMode)

Summary

Gets or sets when the rules of the columns are checked.

Parameters

None

Property value: `WklValidateMode` – A WklValidateMode value; wvmOnLeave (default).

Remarks

A value that breaks a rule is never written, as Access does not save a value that breaks a field's validation rule: the cell editor stays open, the cell shows a red frame with the error symbol and the message as tooltip, and the error bar below the records counts the errors; there is no message box. Escape discards the input. wvmOnLeave checks when the editor is left (Enter, Tab, a click elsewhere), wvmImmediate marks the input while the user types and refuses it when the editor is left, wvmOnSave checks the row for a new record only when it is saved. Existing records are saved cell by cell, so their cells are checked when they are left in every mode. The value is saved with the form.

Read/write.

Code example

Me!Grid1.Object.ValidateMode = wvmImmediate

Inheritance

Declared by WklPropertyGrid.

ClearErrors method

Signature

Sub ClearErrors(Optional ByVal Key As Variant)

Summary

Removes the errors of a record, or every error.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantYes–The record's key; left out for every error.

Remarks

Removes the errors of the rules as well as those of SetError; a rule that is still broken is reported again when its cell is checked next.

Code example

Me!Grid1.Object.ClearErrors

Inheritance

Declared by WklPropertyGrid.

ErrorCount property

Signature

Property Get ErrorCount() As Long

Summary

Gets the number of errors shown.

Parameters

None

Property value: Long – The errors of all cells and records; 0 without errors.

Remarks

Read it in ValidationChange to enable your own buttons, for example a Save button that only makes sense without errors.

Read-only.

Code example

Me!cmdWeiter.Enabled = (Me!Grid1.Object.ErrorCount = 0)

Inheritance

Declared by WklPropertyGrid.

GoToFirstError method

Signature

Sub GoToFirstError()

Summary

Selects the record of the first error and shows its cell.

Parameters

None

Remarks

The first error is the one found first. The list expands the record's parents and scrolls to it, as the button Go to the first error of the error bar does. Raises wkeNotAvailable without errors and outside form view.

Code example

If Me!Grid1.Object.ErrorCount > 0 Then Me!Grid1.Object.GoToFirstError

Inheritance

Declared by WklPropertyGrid.

ErrorSummary property

Signature

Property Get ErrorSummary() As String

Summary

Gets the summary of the errors as the error bar shows it.

Parameters

None

Property value: String – “1 Fehler”, “2 Fehler” …; empty without errors.

Remarks

Read-only.

Code example

Me!lblFehler.Caption = Me!Grid1.Object.ErrorSummary

Inheritance

Declared by WklPropertyGrid.

Value property

Signature

Property Get Value(ByVal Field As String) As Variant
Property Let Value(ByVal Field As String, RHS As Variant)

Summary

Gets or sets the value of a field of the record shown.

Parameters

NameTypeOptionalDefaultDescription
FieldStringNo–The field name.

Property value: Variant – The value; Null for an empty field.

Remarks

Setting writes as the user does: in form mode into the form's record (dirty until Access saves it), with RecordSource into the record source at once. A field the source cannot write is refused with wkeInvalidValue and a text naming the field. Without a record shown: wkeNotConfigured.

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

LabelWidth property

Signature

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

Summary

Gets or sets the width of the caption column in twips (default 2160 = 1.5 inches).

Parameters

None

Property value: Long

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

CategoryCollapsed property

Signature

Property Get CategoryCollapsed(ByVal Category As String) As Boolean
Property Let CategoryCollapsed(ByVal Category As String, RHS As Boolean)

Summary

Gets or sets whether the fields of a category are folded away.

Parameters

NameTypeOptionalDefaultDescription
CategoryStringNo–The category, as in the rows' Band (case ignored).

Property value: Boolean – True: only the category's header is shown.

Remarks

Set in design view it is saved with the form. The user folds and unfolds with a click or Left/Right on the header; the user's folding lasts until the form closes (it is not remembered per user).

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

SetError method

Signature

Sub SetError(ByVal Field As String, ByVal Text As String)

Summary

Marks a field as wrong, as a rule would, or clears its mark.

Parameters

NameTypeOptionalDefaultDescription
FieldStringNo–The field name.
TextStringNo–The message; empty clears the field's mark.

Remarks

None

Code example

None

Inheritance

Declared by WklPropertyGrid.

ErrorText property

Signature

Property Get ErrorText(ByVal Field As String) As String

Summary

Gets the message of a field's error; empty without error.

Parameters

NameTypeOptionalDefaultDescription
FieldStringNo–The field name.

Property value: String

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklPropertyGrid.

FieldEditable property

Signature

Property Get FieldEditable(ByVal Field As String) As Boolean

Summary

Gets whether the user could edit a field.

Parameters

NameTypeOptionalDefaultDescription
FieldStringNo–The field name.

Property value: Boolean – True when the data source can write the field, the row is not ReadOnly and AllowEditing is on.

Remarks

The source decides without any setting: a pass-through or union query, a calculated field of a query, an AutoNumber field or a column a linked ODBC table reports as not updatable cannot be written; in form mode the form's AllowEdits applies too. With a recordset handed over by code every field counts as writable (the grid cannot ask that recordset); a row's ReadOnly decides there. A field without row: wkeKeyNotFound - the rows are those of Rows; in form mode without rows they are made from the form's fields the first time the grid reads the form's record.

Read-only.

Code example

None

Inheritance

Declared by WklPropertyGrid.

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; the Riviera theme of the release package is one), and draws light when the database has no design. Office's own design setting (File › Account) and the Windows app mode are deliberately not followed: a database looks the same on every PC. In high contrast mode the control always uses the system colors, whatever the setting, as Office does. The scheme colors the lines, captions and categories: background and text while BackColor and ForeColor keep their defaults (a color you set wins), headers, lines, selection, focus, group rows and marks. Every text keeps a contrast of at least 4.5:1, also with a database color set whose own colors would fall below it. The control reads the database design when it is first drawn and again with Requery, never while Access draws the form; a design chosen while the form is open shows after Requery or when the form is opened again. The value is saved with the form.

Read/write.

Code example

Me!List1.Object.ColorScheme = wcoDark

Inheritance

Declared by WklPropertyGrid.

EditOnClick property

Signature

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

Summary

Gets or sets whether a single click into an editable cell opens its editor.

Parameters

None

Property value: Boolean – True or False; default True (as in an Access datasheet).

Remarks

With True a click into a cell edits it as in an Access datasheet: the editor opens and the caret lands where the click was (after the last character when the click was right of the text). A drop-down list does not open on the click; its arrow or Alt+Down opens it. A double click selects the word under the caret and raises DblClick and CellDblClick as without the setting. With False a click only selects the record; F2, Enter, typing or a double click open the editor. The click edits only where editing is possible at all: AllowEditing is True, the column is not read-only and the source can be written. A check box, a toggle switch, a command button, a status link and an edit form (EditForm) keep their own click. Ctrl+click and Shift+click still extend the selection. The value is saved with the form; a form saved before version 1.47 takes the default.

Read/write.

Code example

None

Inheritance

Declared by WklPropertyGrid.

AfterRequery event

Signature

Event AfterRequery()

Summary

Occurs after the records were loaded again.

Parameters

None

Remarks

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

DataError event

Signature

Event DataError(ByVal DataErr As Long, ByVal Description As String, ByRef Response As Integer)

Summary

Occurs when loading or saving fails.

Parameters

NameTypeOptionalDefaultDescription
DataErrLongNo–The error number (one of the `WklErrorCode` values).
DescriptionStringNo–The error text.
ResponseInteger (by reference)No–Set to 0 (acDataErrContinue) to suppress the error message.

Remarks

Also raised when a list reads records while it draws, scrolls or follows the keyboard - WklGrid in server mode reads page by page: once per failure, after the current message; the window then shows the text instead of records and reads nothing more until Requery. Code that needs the records receives the error as a run-time error.

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

KeyDown event

Signature

Event KeyDown(ByRef KeyCode As Integer, ByVal Shift As Integer)

Summary

Occurs when a key is pressed while the control has the focus.

Parameters

NameTypeOptionalDefaultDescription
KeyCodeInteger (by reference)No–The key code; set to 0 to discard the key.
ShiftIntegerNo–The state of Shift (1), Ctrl (2) and Alt (4), added.

Remarks

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

KeyPress event

Signature

Event KeyPress(ByRef KeyAscii As Integer)

Summary

Occurs when a character is typed.

Parameters

NameTypeOptionalDefaultDescription
KeyAsciiInteger (by reference)No–The character code; set to 0 to discard the character.

Remarks

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

KeyUp event

Signature

Event KeyUp(ByRef KeyCode As Integer, ByVal Shift As Integer)

Summary

Occurs when a key is released.

Parameters

NameTypeOptionalDefaultDescription
KeyCodeInteger (by reference)No–The key code.
ShiftIntegerNo–The state of Shift (1), Ctrl (2) and Alt (4), added.

Remarks

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

BeforeUpdate event

Signature

Event BeforeUpdate(ByVal Key As Variant, ByVal Action As WklUpdateAction, ByRef Cancel As Integer)

Summary

Occurs before each write into the record source caused by an action of the user.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the affected record; Null for a new record with an AutoNumber key.
Action`WklUpdateAction`No–The kind of change.
CancelInteger (by reference)No–Set to True to cancel the whole operation; everything already written is rolled back.

Remarks

One user action can write several records (for example a copied subtree); all writes of an action share one transaction.

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

AfterUpdate event

Signature

Event AfterUpdate(ByVal Key As Variant, ByVal Action As WklUpdateAction)

Summary

Occurs after each write into the record source caused by an action of the user.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the written record.
Action`WklUpdateAction`No–The kind of change.

Remarks

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

FieldClick event

Signature

Event FieldClick(ByVal Key As Variant, ByVal Field As String)

Summary

Occurs when the user clicks a value.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the record shown.
FieldStringNo–The field name.

Remarks

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

FieldDblClick event

Signature

Event FieldDblClick(ByVal Key As Variant, ByVal Field As String)

Summary

Occurs when the user double-clicks a value.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the record shown.
FieldStringNo–The field name.

Remarks

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

BeforeFieldEdit event

Signature

Event BeforeFieldEdit(ByVal Key As Variant, ByVal Field As String, ByRef Cancel As Integer)

Summary

Occurs before an editor opens for a value.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the record shown.
FieldStringNo–The field name.
CancelInteger (by reference)No–Set to True to keep the value from being edited.

Remarks

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

ValidateField event

Signature

Event ValidateField(ByVal Key As Variant, ByVal Field As String, ByRef NewValue As Variant, ByRef Cancel As Integer)

Summary

Occurs after the user entered a value, before it is written.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the record shown.
FieldStringNo–The field name.
NewValueVariant (by reference)No–The entered value; the procedure can change it.
CancelInteger (by reference)No–Set to True to reject the value; the focus stays in the field and nothing is written.

Remarks

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

AfterFieldUpdate event

Signature

Event AfterFieldUpdate(ByVal Key As Variant, ByVal Field As String)

Summary

Occurs after a value was written.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the record shown.
FieldStringNo–The field name.

Remarks

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

FieldFormat event

Signature

Event FieldFormat(ByVal Key As Variant, ByVal Field As String, ByRef ForeColor As Long, ByRef BackColor As Long, ByRef Bold As Boolean, ByRef Italic As Boolean)

Summary

Occurs while a value is drawn, when FormatEvents is on; the procedure can change its colors and font.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the record shown.
FieldStringNo–The field name.
ForeColorLong (by reference)No–Text color (OLE_COLOR); the procedure can change it.
BackColorLong (by reference)No–Background color (OLE_COLOR); the procedure can change it.
BoldBoolean (by reference)No–Bold text; the procedure can change it.
ItalicBoolean (by reference)No–Italic text; the procedure can change it.

Remarks

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

FocusedFieldChange event

Signature

Event FocusedFieldChange(ByVal Key As Variant, ByVal Field As String)

Summary

Occurs when the focus moved to another field.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the record shown.
FieldStringNo–The field that has the focus now.

Remarks

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

BeforeMasterChange event

Signature

Event BeforeMasterChange(ByVal Values As Variant, ByRef Cancel As Integer)

Summary

Occurs before the grid changes to the records of another master record.

Parameters

NameTypeOptionalDefaultDescription
ValuesVariantNo–The new master values (a value, an array, or Null for no master record).
CancelInteger (by reference)No–Set to True to keep the current records.

Remarks

Raised for changes of the form's record and of MasterRecordset, not when MasterValues is set by code.

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

AfterMasterChange event

Signature

Event AfterMasterChange(ByVal Values As Variant)

Summary

Occurs after the grid was loaded with the records of another master record.

Parameters

NameTypeOptionalDefaultDescription
ValuesVariantNo–The new master values.

Remarks

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

Code example

None

Inheritance

Declared by WklPropertyGrid.

ValidationChange event

Signature

Event ValidationChange()

Summary

Occurs when the errors shown have changed.

Parameters

None

Remarks

After a rule refused an input or is met again, after SetError and ClearErrors, and after a write the data source refused. Read ErrorCount and ErrorSummary for your own summary. Like all events of the control it needs the form's module.

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

Code example

Private Sub Grid1_ValidationChange()
    Me!lblFehler.Caption = Me!Grid1.Object.ErrorSummary
End Sub

Inheritance

Declared by WklPropertyGrid.

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