Skip to content

pyaccesskit.forms.collection

pyaccesskit.forms.collection

Forms: the db.forms collection and :class:Form handles (building forms needs Microsoft Access).

Form

Form(session: Session, name: str)

A saved form (a live, name-based handle).

name property

name: str

The form name.

controls

controls() -> list[ControlInfo]

The form's controls as saved (opens the form hidden in Design view).

check_opens

check_opens() -> None

Open the form in Form view (hidden) and close it; raises if Access reports a problem.

export_text

export_text() -> str

The form in Access's SaveAsText format.

rename

rename(new_name: str) -> None

Rename the form.

drop

drop() -> None

Delete the form.

FormCollection

FormCollection(session: Session)

db.forms.

names

names() -> list[str]

Form names (read through DAO; does not need Microsoft Access).

create

create(
    name: str, *, replace: bool = False, **form_options: Any
) -> FormBuilder[Form]

Start building a form; nothing is created in Access until the builder is saved.

Example::

with db.forms.create("frmCustomers", record_source="Customers") as form:
    form.textbox("CustomerName")
# built atomically here

Parameters:

Name Type Description Default
name str

Form name.

required
replace bool

Rebuild the form if it already exists (atomically swapped in).

False
**form_options Any

Any :class:~pyaccesskit.forms.FormSpec field (record_source, caption, default_view...).

{}

build

build(spec: FormSpec, *, replace: bool = False) -> Form

Build a form from a finished :class:FormSpec (atomically).

drop

drop(name: str) -> None

Delete a form.