Go Home

 

  Data Events Within Access

Event

Event property

It occurs

AfterDelConfirm

AfterDelConfirm (forms)

After you confirm record deletions and the records are actually deleted, or after the deletions are canceled.

AfterInsert

AfterInsert (forms)

After a new record is added to the database.

AfterUpdate

AfterUpdate (forms, controls)

After a control or record is updated with changed data. This event occurs when the control or record loses the focus, or you click Save Record on the Records menu. This event occurs for new and existing records.

BeforeDelConfirm

BeforeDelConfirm (forms)

After one or more records are deleted, but before Microsoft Access displays a dialog box asking you to confirm or cancel the deletion. This event occurs after the Delete event.

BeforeInsert

BeforeInsert (forms)

When you type the first character in a new record, but before the record is added to the database.

BeforeUpdate

BeforeUpdate (forms, controls)

Before a control or record is updated with changed data. This event occurs when the control or record loses the focus, or you click Save Record on the Records menu. This event occurs for new and existing records.

Change

OnChange (controls)

When the contents of a text box or the text box portion of a combo box changes; for example, when you type a character in the control or change the Text property of the control by using a macro or Visual Basic.

Current

OnCurrent (forms)

When the focus moves to a record, making it the current record, or when you requery a form's source of data. This event occurs when a form is first opened, and whenever the focus leaves one record and moves to another. It also occurs when you requery the source of the data for a form; for example, when you click Remove Filter/Sort on the Records menu, or use the ShowAllRecords action or the Requery action.

Delete

OnDelete (forms)

When a record is deleted, but before the deletion is confirmed and actually performed.

NotInList

OnNotInList (controls)

When a value is entered in a combo box that isn't in the combo box list.

Updated

OnUpdated (controls)

When an OLE object's data has been modified.

  Error and Timing Events Within Access

 Event

Event property

It occurs

Error

OnError (forms, reports)

When a run-time error is produced in Microsoft Access while you are in the form or report. This includes Microsoft Jet Database Engine errors, but not run-time errors in Visual Basic. (Since macros can't determine what error has occurred, you normally use Visual Basic event procedures with this event.)

Timer

OnTimer (forms)

When a specified time interval passes, as specified by the TimerInterval property of the form. You can use the Timer event to keep data synchronized in a multiuser environment by requerying or refreshing data at specified intervals.

  Filter Events Within Access

Event

Event property

It occurs

ApplyFilter

OnApplyFilter (forms)

When you click Apply Filter on the Records menu, or click the Apply Filter button on the command bar. This applies the most recently created filter (created using either the Filter by Form feature or the Advanced Filter/Sort window).When you click Filter By Selection after pointing to Filter on the Records menu, or click the Filter By Selection button on the command bar. This applies a filter based on the current selection in the form. When you click Remove Filter/Sort on the Records menu, or click the Remove Filter button on the command bar. This removes any filter (or sort) currently applied to the form. When you close the Advanced Filter/Sort window or the Filter by Form window.

Filter

OnFilter (forms)

When you click Filter By Form after pointing to Filter on the Records menu, or click the Filter By Form button on the command bar. This opens the Filter by Form window, where you can quickly create a filter based on the fields in the form. When you click Advanced Filter/Sort after pointing to Filter on the Records menu. This opens the Advanced Filter/Sort window, where you can create complex filters for the form.

  Focus Events Within Access

Event

Event property

It occurs

Activate

OnActivate (forms, reports)

When a form or report becomes the active window.

Deactivate

OnDeactivate (forms, reports)

When a different Microsoft Access window becomes the active window, but before the window becomes the active window. The Deactivate event does not occur when the focus moves to another application's window, a dialog box, or a pop-up form.

Enter

OnEnter (controls)

Before a control actually receives the focus, either from a control on the same form or when the form opens. This event occurs before the GotFocus event.

Exit

OnExit (controls)

Just before a control loses the focus to another control on the same form. This event occurs before the LostFocus event.

GotFocus

OnGotFocus (forms, controls)

When a control, or a form with no active or enabled controls, receives the focus. A form can get the focus only if all visible controls on a form are disabled, or there are no controls on the form.

LostFocus

OnLostFocus (forms, controls)

When a form or control loses the focus. A form can have the focus only if all visible controls on a form are disabled, or there are no controls on the form.

  Keyboard Events Within Access

Event

Event property

It occurs

KeyDown

OnKeyDown (forms, controls)

When you press any key on the keyboard while a control or form has the focus. A form can have the focus only if all visible controls on the form are disabled, or there are no controls on the form. The KeyDown event also occurs if you send a keystroke to a form or control using the SendKeys action in a macro or the SendKeys statement in Visual Basic.A form also receives all KeyDown events (even those for controls) before they occur for the controls if you set the form's KeyPreview property to Yes. If you hold down a key, the KeyDown event occurs repeatedly.

KeyPress

OnKeyPress (forms, controls)

When you press and release a key or key combination that produces a standard ANSI character while a control or form has the focus. A form can have the focus only if all visible controls on the form are disabled, or there are no controls on the form. For example, you can use the KeyPress event to respond to keystrokes entered in a text box or combo box. For keystrokes not recognized by KeyPress, such as function keys or navigation keys, use the KeyDown and KeyUp events. The KeyPress event also occurs if you send a keystroke that produces a standard ANSI character to a form or control using the SendKeys action in a macro or the SendKeys statement in Visual Basic.A form also receives all KeyPress events (even those for controls) before they occur for the controls if you set the form's KeyPreview property to Yes. If you hold down a key, the KeyPress event occurs repeatedly.

KeyUp

OnKeyUp (forms, controls)

When you release a pressed key while a control or form has the focus. The object with the focus receives all the keystrokes. A form can have the focus only if all visible controls on the form are disabled, or there are no controls on the form. The KeyUp event also occurs if you send a keystroke to a form or control using the SendKeys action in a macro or the SendKeys statement in Visual Basic.A form also receives all KeyUp events (even those for controls) before they occur for the controls if you set the form's KeyPreview property to Yes.  If you hold down a key, the KeyUp event occurs after all the KeyDown and KeyPress events have occurred.

  Mouse Events Within Access

Event

Event property

It occurs

Click

OnClick (forms, controls)

For a control, this event occurs when you press and then release (click) the left mouse button on a control.  For a form, this event occurs when you click a record selector or an area outside a section or control.

DblClick

OnDblClick (forms, controls)

When you press and release (click) the left mouse button twice on a control or its label.  For a form, this event occurs when you double-click on a blank area or record selector on the form.

MouseDown

OnMouseDown (forms, controls)

When you press a mouse button while the pointer is on a form or control.  Canceling the MouseDown event using the CancelEvent action in a macro for a form or control prevents the shortcut menu from being displayed when you right-click the form or control.

MouseMove

OnMouseMove (forms, controls)

When you move the mouse pointer over a form, form section, or control.

MouseUp

OnMouseUp (forms, controls)

When you release a pressed mouse button while the pointer is on a form or control.

  Print Events Within Access

Event

Event property

It occurs

Format

OnFormat (reports)

When Microsoft Access determines which data goes in a report section, but before Microsoft Access formats the section for previewing or printing. Your macro or event procedure can use data in the current record to make changes to the page layout.

NoData

OnNoData (reports)

After Microsoft Access formats a report for printing that has no data (the report is bound to an empty recordset), but before the report is printed. You can use this event to cancel printing of a blank report.

Page

OnPage (reports)

After Microsoft Access formats a page for printing, but before the page is printed.

Print

OnPrint (reports)

After Microsoft Access has formatted the data in a report section, but before the section is printed.

Retreat

OnRetreat (reports)

When Microsoft Access must "back up" past one or more report sections on a page in order to perform multiple formatting passes. This occurs after the section's Format event, but before the Print event. The Retreat event for each section occurs as Microsoft Access backs up past the section. This allows you to undo any changes you have made during the Format event for the section.

  Window Events Within Access

Event

Event property

It occurs

Close

OnClose (forms, reports)

When a form or report is closed and is removed from the screen.

Load

OnLoad (forms)

When a form is opened and its records are displayed. This event occurs before the Current event, but after the Open event.

Open

OnOpen (forms, reports)

When a form is opened but before the first record is displayed.  When a report is opened but before it prints.

Resize

OnResize (forms)

When the size of a form changes. This event also occurs when a form is first displayed.

Unload

OnUnload (forms)

When a form is closed and its records are unloaded, but before it's removed from the screen. This event occurs before the Close event.

 

  
Last Update: March 2005