Presentation is loading. Please wait.

Presentation is loading. Please wait.

MIS333k(Poynor) Chapter 2. Intro to VBA Events Where to plug in your programs?

Similar presentations


Presentation on theme: "MIS333k(Poynor) Chapter 2. Intro to VBA Events Where to plug in your programs?"— Presentation transcript:

1 MIS333k(Poynor) Chapter 2. Intro to VBA Events Where to plug in your programs?

2 MIS333k(Poynor) Click Use Properties Sheet of the control to provide your own VBA logic for the Click event How? Find the “On Click” property and click its builder button to create or edit the VBA code. A common event for buttons and other controls.

3 MIS333k(Poynor) Form Events Open  Load  Resize  Activate  Current Unload  Deactivate  Close These are the common form events.

4 MIS333k(Poynor) Events you can Cancel Private Sub Form_Open (Cancel As Integer) Private Sub Form_Unload (Cancel As Integer) Private Sub Form_BeforeUpdate (Cancel As Integer) To prevent forms opening or closing, and prevent dirty data

5 MIS333k(Poynor) Form_Open Verify user should open this form Cancel efficiently (Cancel = True) When to use this event?

6 MIS333k(Poynor) Form_UnLoad Close button on form is clicked To initiate logic that checks whether to close the form If not closing issue an error message and Cancel the event When to use this event?

7 MIS333k(Poynor) Form_BeforeUpdate To inspect controls or fields for valid data (and cancel the update in case of invalid data) To initiate error messages To prompt for corrections to fields When to use this event?

8 MIS333k(Poynor) Form_Current To coordinate all controls on forms with changes to the record position. Remember the navigation Combo ? To control smart navigation buttons Not to check for errors When to use this event?

9 MIS333k(Poynor) Inside the Form When you move the focus to an existing record on a form, enter or change data in the record, and then move the focus to another record, the following sequence of events occurs for the form: Current  BeforeUpdate  AfterUpdate  Current

10 MIS333k(Poynor) Inside a Control When you change the text in a text box or in a combo box, the Change event occurs. But it occurs before you move to a different control or record (before the BeforeUpdate and AfterUpdate events occur). The following sequence of events occurs for each key you press in a text box or in the text box portion of a combo box: KeyDown  KeyPress  Change  KeyUp

11 MIS333k(Poynor) Click The Click event applies only to forms, form sections, and controls on a form This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself. MouseDown  MouseUp  Click  DblClick  Click

12 MIS333k(Poynor) Help? Look for “Event properties reference” In Help: Index In Help: Answer Wizard


Download ppt "MIS333k(Poynor) Chapter 2. Intro to VBA Events Where to plug in your programs?"

Similar presentations


Ads by Google