DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6)

Similar documents
Event Demonstrator. occurs when user changes data displayed on a bound form. occurs when user returns a form s data to its original state

Respond to Data Entry Events

JavaScript and Events

DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, X405.5)

DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, X405.5)

Hell is other browsers - Sartre. The touch events. Peter-Paul Koch (ppk) DIBI, 28 April 2010

CST242 Windows Forms with C# Page 1

To complete this database, you will need the following file:

The American University in Cairo. Academic Computing Services. Access prepared by. Aya Saad. Spring 2003

GUJARAT TECHNOLOGICAL UNIVERSITY DIPLOMA IN INFORMATION TECHNOLOGY Semester: 4

Hell is other browsers - Sartre. The touch events. Peter-Paul Koch (ppk) WebExpo, 24 September 2010

Not For Sale. Using and Writing Visual Basic for Applications Code. Creating VBA Code for the Holland Database. Case Belmont Landscapes

Microsoft Excel Keyboard Shortcuts

VBA Foundations, Part 7

PowerLink Solution Builder User Guide

A DVANCED T OPICS IN A CCESS: MACROS

Catching Events. Bok, Jong Soon

PowerPoint Slide Basics. Introduction

Visual Basic.NET. 1. Which language is not a true object-oriented programming language?

Access Forms Masterclass 5 Create Dynamic Titles for Your Forms

2.1 Logging on to FieldManager Software

1 Ctrl + X Cut the selected item. 2 Ctrl + C (or Ctrl + Insert) Copy the selected item. 3 Ctrl + V (or Shift + Insert) Paste the selected item

DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, X405.5)

Working with Excel CHAPTER 1

Pearson Education Limited Edinburgh Gate Harlow Essex CM20 2JE England and Associated Companies throughout the world

Microsoft Excel > Shortcut Keys > Shortcuts

To complete this database, you will need the following file:

Working with Excel involves two basic tasks: building a spreadsheet and then manipulating the

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

MICROSOFT EXCEL KEYBOARD SHORCUTS

Fig. 1 Relationship View of Northwind.mdb

Section 5: Editing Cells

Dynamic Web Programming BUILDING WEB APPLICATIONS USING ASP.NET, AJAX AND JAVASCRIPT

ASNA Visual RPG for Smarties

HOUR 4 Understanding Events

GUI Event Handling 11. GUI Event Handling. Objectives. What is an Event? Hierarchical Model (JDK1.0) Delegation Model (JDK1.1)

Working with Macros. Creating a Macro

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6)

WINDOWS NT BASICS

Answer: C. 7. In window we can write code A. Immediate window B. Locals window C. Code editor window D. None of these. Answer: C

Example 1 Simple Broadcast: A broadcast is sent to a target audience. The may contain a link directing the user to a web page.

ICDL & OOo BASE. Module Five. Databases

Copyright 2015 Integrated Environmental Solutions Limited. All rights reserved.

Mach4 CNC Controller Screen Editing Guide Version 1.0

MaintScape Training Course Table of Contents

Digital City: Introduction to 3D modeling

PowerPoint Introduction. Video: Slide Basics. Understanding slides and slide layouts. Slide Basics

Chapter 6: Creating Custom Forms. Guide to Oracle 10g

Text Box Frames. Format Text Box

239 Excel Keyboard Shortcuts

Respond to Errors and Unexpected Conditions

BasicScript 2.25 User s Guide. May 29, 1996

AutoCAD 2009 User InterfaceChapter1:

FEATURE INDEX TAB MIX PLUS: LINKS... 3 TAB MIX PLUS: EVENTS TAB OPENING... 4 TAB MIX PLUS: EVENTS TAB FOCUS... 5

2 Getting Started. Getting Started (v1.8.6) 3/5/2007

University of Technology Laser & Optoelectronics Engineering Department Visual basic Lab. LostFocus Resize System event

Microsoft Office 2010: Introductory Q&As Access Chapter 2

Getting Started (1.8.7) 9/2/2009

Switch between open apps Close the active item, or exit the active app

Flip-Q. Version 2.4. Overview

Getting Started with. Microsoft Office 2010

Display Systems International Software Demo Instructions

The scripting system handles two types of components: Visual and Non-visual components.

KEYBOARD SHORTCUTS AND HOT KEYS

Table of Contents WINDOWS 95. What is Windows 95? Features LINC TWO

Peripheral Devices devices attached to the CPU (computer)

CSE 154 LECTURE 10: MORE EVENTS

Contents. More Controls 51. Visual Basic 1. Introduction to. xiii. Modify the Project 30. Print the Project Documentation 35

Interacting with Measurement Studio Graphs in Visual Basic Heather Edwards

What s New in Access Learning the history of Access changes. Understanding what s new in Access 2002

CST272 Getting Started Page 1

Appendix J: Using Shortcut Keys and Shortcut Menus

CHAPTER 1 COPYRIGHTED MATERIAL. Getting to Know AutoCAD. Opening a new drawing. Getting familiar with the AutoCAD and AutoCAD LT Graphics windows

Section 1 Creating Mail Merge Files

ekaizen Lessons Table of Contents 1. ebook Basics 1 2. Create a new ebook Make Changes to the ebook Populate the ebook 41

Microsoft Windows XP. Operating System. Starting Windows XP. You might be asked to enter your username and password

Windows 2000 Safe Mode

Click the buttons in the interactive below to learn how to navigate the Access window.

ID Flow 6.x Getting Started Guide. An Introduction to ID Flow

Standard Toolbar. Main Toolbar. Page Sorter. Action Toolbar

Contents. Using Interpreters... 5 Using Compilers... 5 Program Development Life Cycle... 6

PowerPoint Spring 2002

The Fundamentals. Document Basics

Scripting with CAMMaster and Visual Basic 2008

First we start by importing our image assets to our "Chapters" card

User Interfaces. Lecture 19. Cocoa: Mouse and Keyboard Events. Hamza Bennani September 18, 2018

A method is a procedure that is always associated with an object and defines the behavior of that object.

729G26 Interaction Programming. Lecture 4

Ignite UI Release Notes

JavaScript: More Syntax and Using Events

NiceForm User Guide. English Edition. Rev Euro Plus d.o.o. & Niceware International LLC All rights reserved.

Power Point. Created with the Freeware Edition of HelpNDoc: Single source CHM, PDF, DOC and HTML Help creation

Getting started 7. Setting properties 23

MS Word Basic Word 2007 Concepts

PHLI Instruction (734) Introduction. Lists.

Javascript Events. Web Authoring and Design. Benjamin Kenwright

Investigator Site OC RDC PDF User Guide

Getting started 7. Setting properties 23

Customizing Windows XP

Windows Me Navigating

Transcription:

Technology & Information Management Instructor: Michael Kremer, Ph.D. Database Program: Microsoft Access Series DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) Section 5

AGENDA 8. Events in MS Access

Events in MS Access 8.

8.1 OVERVIEW OF EVENTS 137 MS Access is event driven, better yet, the user s action case events to trigger. Access comes already structured with a couple of hundreds event procedures, its arguments and whether they are cancelable or not. Certain events are not triggered when caused programmatically. User actions: Data updates, keyboard, mouse, certain computer and network states. One action may cause a whole sequence of events.

8.1 OVERVIEW OF EVENTS 138 Unless you write code and attach it to those events, nothing is going to happen. When code or macro is attached to an event, it is executed automatically when the event takes place. The most difficult part is to figure out which event to use for which situation.

8.1 OVERVIEW OF EVENTS Event Category Applies to Events Mouse events: When a mouse is moved or the left button is clicked. Forms, Form Sections, Controls Click, DoubleClick, MouseDown, MouseUp, MouseMove Keyboard events When keys on the keyboard are pressed or when the Sendkeys action or method is used. Forms, Controls KeyDown, KeyUp, KeyPress 139 Window events When a form or report is opened, closed, or resized. Focus events When an object becomes active or loses focus. Data events When data is added, deleted, or changed. Filter events When a filter is created or applied. Print/Format events When a report is formatted for printing or printed. Error events When an error occurs. Timing events When a specified period of time is elapsed. Reference events When a reference is added or removed. Forms, Reports Forms, Reports, Controls Forms, Controls Forms Reports, Report Sections Forms, Reports Forms Application Open, Load, Unload, Close, Resize Enter, GotFocus, Exit, LostFocus, Activate, Deactivate Current, BeforeInsert, AfterInsert, Delete, Dirty, BeforeDeleteConfirm, AfterDeleteConfirm, BeforeUpdate, AfterUpdate, Change, Updated, NotInList Filter, ApplyFilter Format, Print, Retreat, NoData, Page Error Timer ItemAdded, ItemRemoved

8.2 SEQUENCE OF EVENTS 140

8.2 SEQUENCE OF EVENTS 141 Besides the obvious event, many other events are triggered. Event naming convention: Form level events Section-level events Control-level events After form is opened, first control based on tab order receives focus. Form_ FormHeader_, Detail_, FormFooter_ controlname_

8.3 RESPONDING OF EVENTS Respond to an event in the following way: First, choose the right event Place a reference in the event property. Event Property 142 Event Property Value Embedded Macro (New in Access 2007) Standalone Macro Function (not recommended) Event Procedure

8.3 RESPONDING OF EVENTS 143 Most event properties start with the preposition ON. That means, exactly when the event takes place the event handler is executed. Some other event handlers execute Before or After an event. Event Handlers: Macro Event procedure Function call (not recommended, only function, not sub) Embedded Macro (New in Access 2007)

8.3 RESPONDING OF EVENTS 144 When an event procedure is chosen as a handler, MS Access automatically provides the framework for the procedure including arguments. Event procedure name: Objectname_eventname(arguments) Do not change the name of the procedure or it s arguments!! Before creating event procedures, make sure to name your objects according to naming convention! Why? If you change the name of an object after creating the event procedure, you break the link.

8.3 RESPONDING OF EVENTS 145 Event procedures carry additional arguments, such as Cancel. This means, that the event is cancelable. Other events carry other parameters about system states.

8.3 RESPONDING OF EVENTS 146 Respond to an event in the following ways: Select standalone macro: Set to Event Procedure: Clicking inside an empty event property displays Choose Builder dialog box: Macro Builder Embedded Macro Expression Builder Select function Code Builder Create event procedure Build button

8.3 RESPONDING OF EVENTS 147 Certain action cannot be trapped: Select a menu/ribbon command Scrolling Clicking the right/middle button Selecting a toolbar button Record locking Create customized record locking procedure using timer event. Use macros sparingly, if at all: Error handling, no looping, difficult to debug, no transactions, passing parameters.

8.4 FORM EVENTS 148 Opening a form: Open Load Activate Open Event: Make changes to data source, such as filtering/selecting records using criteria Open another form, move focus to a specific control, or ask for a criteria from the user. Load Event: Calculate data, change data in controls, or open another form based on linked values. If form contains controls: Enter GotFocus If no controls, then the form receives focus. If another form was active before: Deactivate

8.4 FORM EVENTS Events on a form occur at three levels: Form level: Higher level events (opening, closing) Section level: Clicking or moving mouse Control level: Entering, Exiting, Focus, Data changes Control events vary by control type. 149

8.4 FORM EVENTS 150 Opening and closing a form seems like a trivial process. Opening a form Opening a form having a control without controls

8.4 FORM EVENTS If form contains a sub form, then sub form events are fired first. 151 When the form containing a sub form is closed, the sub form events are fired last.

8.4 FORM EVENTS Closing a form having pending changes 152

8.4 FORM EVENTS 153

8.4 FORM EVENTS 154

8.4 FORM EVENTS 156 Minimize, Maximize, Restore trigger the resize event. Dragging the border to size a form triggers the resize event multiple times. If multiple forms are open, one form is minimized. Minimizing Maximizing

8.4 FORM EVENTS 157 Events between controls on different forms. Form is deactivated, control loses focus, but is not exited. Opening form 2 Closing form 2

8.5 DATA RELATED EVENTS 157 Record and Control buffer at form level. When data is bound to a form, first the entire record is loaded into the record buffer. Active control value is loaded into control buffer.

8.5 DATA RELATED EVENTS 158 These two buffers represent the two different undo levels. Press [Esc] once to undo the current field, press [Esc] again to undo the entire record. Whenever there are pending changes, form is set to dirty. Use dirty event to check whether data changes have been made. Also key events are triggered because data changes mean user typed values.

8.5 DATA RELATED EVENTS 159 When a value is changed in a control and user tabs over to the next control: Although no key was pressed in the City control, the [tab] key acts like a bridge. KeyDown happens in CustomerName control, KeyPress and KeyUp in the City control. BeforeUpdate and AfterUpdate events are triggered at control level. BeforeUpdate: Before data is saved into record buffer. AfterUpdate: Record buffer is now updated

8.5 DATA RELATED EVENTS 160 When entire record is saved, the following events take place. First Record, City Control: Data is changed: KeyDown, KeyPress, Form_Dirty, Change, KeyUp [Tab] key is pressed: KeyDown, BeforeUpdate, AfterUpdate Form level events: BeforeUpdate, AfterUpdate City control level events: Exit, LostFocus Form level events: Current Second Record, Customer Control Enter, GotFocus, KeyPress, KeyUp

8.5 DATA RELATED EVENTS 161 Between Before and AfterUpdate at control level, current record buffer is updated with current control buffer. Between Before and AfterUpdate at form level, database is updated with current record buffer. Use the BeforeUpdate event at the control level: Validate the value entered in a control Compare the changed value with the old value (OldValue property) Use the AfterUpdate at the control level: Change the value the user entered React to the change in value and set a value in another control

8.5 DATA RELATED EVENTS 162

8.5 DATA RELATED EVENTS 163 Use the BeforeUpdate event at the form level: Validate the data entered (cross validation of fields) Make changes in current record before the record is saved Use the AfterUpdate event at the form level: To react to the saving of the record

8.5 DATA RELATED EVENTS 164

8.5 DATA RELATED EVENTS 165