1 / 12

Chapter 2. Intro to VBA Events

Chapter 2. Intro to VBA Events. Where to plug in your programs?. Click . A common event for buttons and other controls. Use Properties Sheet of the control to provide your own VBA logic for the Click event

fay
Download Presentation

Chapter 2. Intro to VBA Events

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Click A common event for buttons and other controls. • 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. MIS333k(Poynor)

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

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

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

  6. Form_UnLoad When to use this event? • 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 MIS333k(Poynor)

  7. Form_BeforeUpdate When to use this event? • 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 MIS333k(Poynor)

  8. Form_Current When to use this event? • 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 MIS333k(Poynor)

  9. 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 MIS333k(Poynor)

  10. 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 MIS333k(Poynor)

  11. 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 MIS333k(Poynor)

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

More Related