Respond to Data Entry Events

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 Errors and Unexpected Conditions

Understanding the MsgBox command in Visual Basic

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

Find and Filter Records on a Form

An InputBox( ) function will display an input Box window where the user can enter a value or a text. The format is

variables programming statements

MAIL MERGE USING MS WORD 97

MICROSOFT EXCEL 2000 LEVEL 5 VBA PROGRAMMING INTRODUCTION

Visual Programming 1. What is Visual Basic? 2. What are different Editions available in VB? 3. List the various features of VB

The name of this chapter is Dealing with Devices, but of

Table of Contents Data Validation... 2 Data Validation Dialog Box... 3 INDIRECT function... 3 Cumulative List of Keyboards Throughout Class:...

Put Final Touches on an Application

Using Microsoft Word. Text Editing

Creating a main document and a data source by using the Mail Merge Helper. Performing and viewing a merge by using the View Merged Documents button.

Tutorial 5 Advanced Queries and Enhancing Table Design

Office 2016 Excel Basics 06 Video/Class Project #18 Excel Basics 6: Customize Quick Access Toolbar (QAT) and Show New Ribbon Tabs

MgtOp 470 Business Modeling with Spreadsheets Sample Midterm Exam. 1. Spreadsheets are known as the of business analysis.

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

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

XnView 1.9. a ZOOMERS guide. Introduction...2 Browser Mode... 5 Image View Mode...15 Printing Image Editing...28 Configuration...

Highline Excel 2016 Class 13: One Lookup Value to Return Multiple Items: Array Formula

You ll notice at the bottom of the file menu there is a list of recently opened files. You can click a file name in the list to re-open that file.

Complete List of Windows 8 Keyboard Shortcuts Keyboard Shortcuts for Desktops

Excel Macro Record and VBA Editor. Presented by Wayne Wilmeth

GENERAL NAVIGATION REFERENCE GUIDE FOR BANNER 7.X

Access 2003 Introduction

JIDE Shortcut Editor Developer Guide

IFA/QFN VBA Tutorial Notes prepared by Keith Wong

FM 4/100 USB Software for OSX

Changing How the Keyboard Works in Windows 7

XnView Image Viewer. a ZOOMERS guide

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

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

Microsoft Office Excel 2003

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

Angel International School - Manipay 1 st Term Examination November, 2015

Excel & Visual Basic for Applications (VBA)

Access Forms Masterclass 5 Create Dynamic Titles for Your Forms

Give users a control that makes entering dates as easy as it is in Intuit Quicken.

Events. Event Handler Arguments 12/12/2017. EEE-425 Programming Languages (2016) 1

A DVANCED T OPICS IN A CCESS: MACROS

MCS 2 USB Software for OSX

Word 2016 Tips. Rylander Consulting

VBA Excel 2013/2016. VBA Visual Basic for Applications. Learner Guide

CS130/230 Lecture 12 Advanced Forms and Visual Basic for Applications

Keyboard : All special keys : Enter, Del, Shift, Backspace,Tab Contributors Dhanya.P Std II. Reviewers Approval Date Ref No:

Microsoft Excel 2013 Unit 1: Spreadsheet Basics & Navigation Student Packet

Microsoft Access 2010 Level III

Angel International School - Manipay 1 st Term Examination November, 2015

Copyright 2004, Mighty Computer Services

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

Instructions for Crossword Assignment CS130

6/14/2010. VBA program units: Subroutines and Functions. Functions: Examples: Examples:

In the previous chapter, I showed you how to build a program

Hands-On-Labs for. Microsoft Identity Integration Server Microsoft Identity Integration Server 2003 Hand-On-Labs

BasicScript 2.25 User s Guide. May 29, 1996

Access 2007 Introduction

Course: US02EBCA02 (Working with RDBMS for Small Scale Organizations) Effective from June

Perceptive Intelligent Capture Project Migration Tool. User Guide. Version: 2.0.x

Access Intermediate

Highline Excel 2016 Class 09: Date Functions

Accessibility. Mike McBride

3 IN THIS CHAPTER. Understanding Program Variables

Peripheral Devices devices attached to the CPU (computer)

d2vbaref.doc Page 1 of 22 05/11/02 14:21

JUN / 04 VERSION 7.1 FOUNDATION

Programming Concepts and Skills. Arrays continued and Functions

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

Log into your portal and then select the Banner 9 badge. Application Navigator: How to access Banner forms (now called pages.)

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

Formulas and Functions

PC shortcuts & Mac shortcuts

Introduction to Microsoft Office PowerPoint 2010

MICROSOFT EXCEL KEYBOARD SHORCUTS

Using the Customize Dialog Box

VBA. VBA at a glance. Lecture 61

2D1640 Grafik och Interaktionsprogrammering VT Good for working with different kinds of media (images, video clips, sounds, etc.

Lookup Project. frmlookup (Name: object is a combo box, style 2); use 4 labels: 2 for phone, 2 for mail. MsgBox Function:

Human Factors Engineering Short Course Topic: A Simple Numeric Entry Keypad

KB9000 Programmable Touch Bumpbar PROGRAMMING MANUAL

Microsoft Excel > Shortcut Keys > Shortcuts

Variable Data Printing in Fiery Controllers. Exercise 1: Fiery FreeForm 1

ASSISTIVE CONTEXT-AWARE TOOLKIT (ACAT)

12/14/2016. Errors. Debugging and Error Handling. Run-Time Errors. Debugging in C# Debugging in C# (continued)

Release Notes for April StatCrunch Updates

Private/Public Saved Searches

Access Intermediate

Recommended GUI Design Standards

Microsoft Office 2010: Introductory Q&As Access Chapter 3

STAR OFFICE WRITER. Lesson 1

Microsoft Excel Keyboard Shortcuts

Using Microsoft Word. Paragraph Formatting. Displaying Hidden Characters

Use Default Form Instances

1. About AP Invoice Wizard

Getting started 7. Writing macros 23

SECTION 4 USING QUERIES. What will I learn in this section?

IFA/QFN VBA Tutorial Notes prepared by Keith Wong

Enterprise Edge Attendant Console User Guide

Simple sets of data can be expressed in a simple table, much like a

Transcription:

Respond to Data Entry Events Callahan Chapter 4 Understanding Form and Control Events Developer s Goal make data entry easy, fast, complete, accurate Many form- and control-level events occur as user works within your application Events provide an opportunity for your application to respond to user action Table on Callahan page 68 Event Demonstrator database and webcast Covered in this chapter/webcast Form Events BeforeUpdate, KeyDown Control Events Enter, Exit, KeyDown, KeyPress, KeyUp, AfterUpdate 1

Performing Actions as the User Moves in a Form Several events occur as user navigates controls on a form we experimented with them in the Event Demonstrator database Enter and Exit only occur when a user navigates to another control on the same form user clicks another control on the same form Exit(1 st control) LostFocus(1 st control) Enter (2 nd control) GotFocus(2 nd control) Enter and Exit don t occur when a user navigates to another control on a different form user clicks a control on a different form LostFocus(control) Deactivate(form 1) Activate(form 2) GotFocus(control) Changing a Control s Property Setting Change the Background Color of a Combo Box to indicate that was the active control Private Sub Combo51_Enter() Me.AllowEdits= True Combo51.BackColor = 16777215 'change background to white Private Sub Combo51_Exit(Cancel As Integer) Me.AllowEdits= False Combo51.BackColor = 12632256 'change background to gray If the control is on same form whose VB code is executing Me.controlname.property = value If the control is on another open form Forms!formname!controlname.property = value 2

Performing Actions as the User Changes Data AfterUpdateevent (control) occurs after a control s data has been updated, and just before the control is exited Have the Dear field fill automatically whenever the First Name field is changed but only when the Dear field is blank (don t overwrite an existing Dear value) Private Sub FirstName_AfterUpdate() 'Copy the FirstNamevalue to the Dear control If IsNull(Dear) Then Dear = FirstName Responding to Keyboard Events KeyPress event occurs when a user presses and releases a key or key combination that corresponds to an ANSI code while a form or control has the focus ignores function keys, navigation keys, SHIFT, CTRL, ALT KeyUp event occurs when a user releases a key while a form or control has the focus KeyDown event occurs when a user presses a key while a form or control has the focus typically used to trigger code when a user presses function keys (F1-F12) navigation keys (Home, End, Page Up, Page Down,,,,, Tab) combinations of keys involving SHIFT, CTRL, ALT numeric keypad top-row number keys Event Demonstrator database 3

Using KeyDown KeyCode an integer that indicates which key was pressed Shift an integer that indicates the status of Shift, Control, and Alt keys 0 = none 1= Shift 2= Ctrl 4= Alt any other value is a sum indicating multiple keys held (eg: 3=[Ctrl]+[ Shift]) Define [Ctrl]+[1] as keyboard shortcut to automatically enter City, State, Country for New York contacts Private Sub City_KeyDown(KeyCode As Integer, Shift As Integer) ' If key is Ctrl+1, enter the values for New York If KeyCode = 49 And Shift = 2 Then 'Ctrl+1was pressed City = "New York" StateOrProvince = "NY" Country = "USA" Make the Keyboard Handler Work Anywhere on the Form By default, only the active control receives keystrokes KeyPreview property a form property that determines whether the form receives keyboard events before passing them to the active control used here so the [Ctrl]+[1] shortcut could work anywhere on the form, not just the City field Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) ' If key is Ctrl+1, enter the values for New York If KeyCode = 49 And Shift = 2 Then 'Ctrl+1was pressed City = "New York" StateOrProvince = "NY" Country = "USA" 4

Practice Time Open Artie s List database frmrestaurant What happens when a user presses [PageUp] or [PageDown]? Suppose we want to disable [PageUp] and [PageDown] no matter which control the user is in how learn codes for [PageUp] and [PageDown]? Help System Access Object Events Form KeyDown event how can you make your VBA code ignore a keystroke? build this code, then test that [PageDown][PageUp] are now ignored Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) ' Ignore PageUp/PageDn keys If KeyCode = vbkeypageup Or KeyCode= vbkeypagedownthen KeyCode= 0 Validating Data Access provides many opportunities to validate data Data type (field) eg: Access rejects the value abc in a Number field Input Mask property (field) PostalCode, WorkPhone, MobilePhone, FaxNumber fields used them Required property (field) Access won t store the record if a Required field is left Null required each record have a LastName and FirstName Validation Rule property (field-level or record-level) used a record-level Validation Rule to require a work or mobile phone number ([WorkPhone] & [MobilePhone]) Is Not Null Before Update event (form) the most versatile way to validate form data fires just before a new or modified record is saved used to execute VBA code to check the form s data, then either allow the save or cancel the save & require corrective action 5

Using Form_BeforeUpdate Private Sub Form_BeforeUpdate(CancelAs Integer) ' if the user entered an address, check for a postal code Dim strmessage As String Dim intoptions As Integer variables = named storage locations in memory Dim bytchoiceas Byte If Not IsNull(Address) And IsNull(PostalCode) Then strmessage = "You didn't enter a postal code. Save anyway?" intoptions = vbquestion+ vbokcancel bytchoice= MsgBox(strMessage, intoptions) If bytchoice = vbcancelthen PostalCode.SetFocus Cancel = True ' go back to PostalCode ' cancel saving the record Dueling Message Boxes Message Box statement (Callahan 2) displays a message in a modal dialog box code execution halts until after the message box is closed syntax MsgBox message[, icontype][, title] example MsgBox "This is a Message", vbcritical, "Title Goes Here" Message Box function displays message in a modal dialog box, waits for user to click a button, returns an integer indicating which button was clicked code execution halts until after the message box is closed syntax MsgBox(prompt[, buttons][, title][, helpfile, context]) example intanswer= MsgBox("Are You Sure?", vbyesno+ vbquestion, "Confirm File Deletion") Demo: MsgBox Function in Immediate Window and Help 6