Forms z Event procedures forms and controls z

  • Slides: 22
Download presentation
Forms z Event procedures forms and controls z Filters z Validating data in a

Forms z Event procedures forms and controls z Filters z Validating data in a form z User-defined functions

Form Events

Form Events

Form Events

Form Events

Form Events

Form Events

Form Events

Form Events

Form Events

Form Events

Form Events

Form Events

Form Events

Form Events

Control Events

Control Events

Control Events

Control Events

Control Events

Control Events

Control Events

Control Events

Filters z Filtering allows users to choose own subset of rows and supply own

Filters z Filtering allows users to choose own subset of rows and supply own ordering from a table or query z Form methods and properties yfilter by selection yfilter by form yapply filter method y. Filter and Filter. On property y. Filter event and Apply. Filter event

Filters z Filter by selection yuser selects field to filter and clicks Filter by

Filters z Filter by selection yuser selects field to filter and clicks Filter by selection button z Filter by form yuser clicks Filter by form button, selects value from a list for a particular field, and clicks Apply filter button z Apply. Filter ymethod of the Do. Cmd object

Filters z Filter property ytakes the form of an SQL WHERE clause z Filter.

Filters z Filter property ytakes the form of an SQL WHERE clause z Filter. On property ydetermines whether a record source is being filtered z Examples. . .

Filters Filter property [Last. Name] = “Smith” And [City] Like “S*” Filter. On property

Filters Filter property [Last. Name] = “Smith” And [City] Like “S*” Filter. On property If Filter. Options = 2 Then Me!lbl. Warning. Visible = Me. Filter. On Else Me. Filter. On = False End If

Filters z With Apply. Filter method, can specify y. WHERE clause yquery yboth yexample

Filters z With Apply. Filter method, can specify y. WHERE clause yquery yboth yexample Do. Cmd. Apply. Filter. Name: =“qry. Simple” Do. Cmd. Apply. Filter Where. Condition: =“ID = 5”

Filter Event z Two arguments y. Cancel -- when set to true in the

Filter Event z Two arguments y. Cancel -- when set to true in the procedure, cancels the filter event y. Filter. Type x 0 -- ac. Filter. By. Form x 1 -- ac. Filter. Advanced z Uses ymake certain controls are disabled (reset with Apply. Filter event) yclean out a previous Filter property

Apply. Filter Event z Two arguments y. Cancel -- when set to true, cancels

Apply. Filter Event z Two arguments y. Cancel -- when set to true, cancels the procedure y. Apply. Type x 0 -- ac. Show. All. Records (removes filter) x 1 -- ac. Apply. Filter (applies new filer) x 2 -- ac. Close. Filter. Window (tried to close filter window without specifying a new filter

Apply. Filter Event z Uses ytrap attempts to remove a filter or set a

Apply. Filter Event z Uses ytrap attempts to remove a filter or set a new one ymodify filter expression manually yreset display of form before Filter event was applied ychange or update display of form before Access applies filter

Validating Data in a Form z Blank fields can often be checked using Before.

Validating Data in a Form z Blank fields can often be checked using Before. Update event z Controls can often be validated using Lost. Focus event z Errors that occur when attempting to save can be trapped with the Error event

User-Defined Functions z Why create functions? y. For code used multiple times either in

User-Defined Functions z Why create functions? y. For code used multiple times either in a class module (private functions) or through the entire application (public functions) yexample Public Function Close. Open(y as String) On Error Resume Next Do. Cmd. Close Do. Cmd. Open. Form y End Function