Skip to content

pyaccesskit.forms.spec

pyaccesskit.forms.spec

Form specifications.

FormSpec

Bases: SpecModel

A form built by PyAccessKit.

Attributes:

Name Type Description
name str

Form name.

record_source str | None

Table, query or SQL the form is bound to (None for an unbound form).

caption str | None

Window caption.

default_view FormView

Single, continuous, datasheet or split form.

layout LayoutKind

How controls without at= are placed (AUTO picks stacked or tabular).

header bool | None

Show the form header/footer sections; None = automatically when needed.

width Length | None

Minimum form width (grown to fit the controls).

controls Items[ControlSpec]

Controls in tab order.

on_load Vba | None

VBA run by the form's Load event.

on_current Vba | None

VBA run by the form's Current event.

module_code str | None

Extra VBA appended to the form's module (helper procedures...).

option_explicit bool

Put Option Explicit at the top of the generated module.

properties dict[str, PropertyValue]

Other Access form properties to set verbatim (escape hatch).

has_module property

has_module: bool

Whether the form needs a class module (event procedures or extra code).

resolved_controls

resolved_controls() -> tuple[ControlSpec, ...]

Controls with default names filled in (bound field name, else <Kind><n>).

event_bindings

event_bindings() -> tuple[EventBinding, ...]

Every event procedure the form needs, form events first.

module_text

module_text() -> str | None

The complete VBA text of the form's module, or None if it needs none.

label_name_for

label_name_for(control_name: str) -> str

The name of a control's attached label (CustomerName → CustomerName_Label).

Access names are limited to 64 characters. For long control names the name is shortened and a hash of the full control name keeps it unique and stable (collisions are still checked by :class:FormSpec).