Appendix A. Appendix

The Devil is in the details—and in the case of Access, it’s in the technical appendix. Here you’ll find behind-the-scenes particulars about maintaining your Access installation; tips on Access newsgroups that you can turn to for help; dozens of tables detailing Access functions, controls, actions, events; and more.

Installation Checklist

When casual users install Access, they generally run the installer and when it’s done, they assume that’s that. But Access power users and professional developers know that keeping Access healthy means going beyond what comes out of the box. With some simple preventive maintenance—installing service packs, re-registering DLLs, and so on—you can avoid headaches and mysterious failures too numerous to list. Here are the essentials to keeping Access healthy.

Keep Windows Up-to-Date

Whatever version of Windows you’re running, make sure that you have applied the latest security patches and updates. The easiest way to do this is by pointing Internet Explorer at http://windowsupdate.microsoft.com.

Keep Office Up-to-Date

Same deal for Microsoft Office. Office updates can be found at http://office.microsoft.com/officeupdate.

Keep Jet 4.0 Up-to-Date

Jet is the database engine under Access’s hood, and to minimize bugs, it’s essential you apply the latest Jet service packs. (See MSKB 239114 for detailed instructions.) To find out what version of Jet you have, locate the Msjet40.dll file; it’s usually in the WindowsSystem32 or WindowsSystem folder. Right-click it, choose Properties, and look on the Version tab. If your version is earlier than 4.0.8618.0, it is not up-to-date. Even if you have just purchased and installed the latest version of Access, you can’t assume that Jet is up-to-date. (On the other hand, if you have applied the latest service packs, and then upgraded to a new version of Access, you should be fine.)

Install All Access Features

By default, Setup leaves out some Access and Office features you might want later—such as some Wizards or certain Visual Basic Help files. The idea is that you can install them the first time you need them, but that’s kind of a pain, having to fetch the install CD over and over. To see what you’re missing, run the Add or Remove Programs control panel, click the Microsoft Office entry, then the Change button. This brings up the Maintenance Mode screen. Click the “Add or Remove Features” button, open the Microsoft Access for Windows item, and look for features with a “1” on them. These are features that are installed on “first use.” Save yourself time—click each feature’s icon and select “Run from My Computer.” When you’re done, click the Update Now button and you’ll install everything you’ve selected.

Re-Register DLLs

In addition to keeping your software up-to-date, you may occasionally need to re-register DLLs. A DLL file is an external library of functions that Access needs to work properly. DLLs can be shared among different programs, and it’s all too easy for one version of a DLL to be inadvertently replaced by another, or for a DLL’s listing in the Windows Registry to become corrupted. If this happens, you’ll lose the functionality provided by that DLL (for example, importing and exporting text depends on Mstext40.dll). Throughout this book we’ve pointed out how to recognize this situation; here we’ll just explain how to fix it.

To re-register a DLL (in this example, Mstext40.dll):

  1. Find the regsvr32.exe utility. It should be on your system, typically in Windowssystem32. If not, do a file search for it. If you can’t find it, download it from Microsoft (see MSKB 267279 for the details).

  2. Click Start → Run, and type something like:

    	C:Windowssystem32
    egsvr32.exe C:Windowssystem32Mstext40.dll
    

    and press Enter (see Figure A-1).

RegSvr32 gives a confirmation message when it runs without error.
Figure A-1. RegSvr32 gives a confirmation message when it runs without error.

Install ODBC Drivers

If you’re using Access as a frontend to another database (such as SQL Server, Oracle, or MySQL), you’ll need ODBC drivers specific to that database. (If you’re connecting to SQL Server, you can also connect via OLEDB.) ODBC drivers for Oracle and SQL Server come standard with Access, but it’s a good idea to update those drivers by getting the latest version of MDAC (Microsoft Data Access Components) for your version of Windows. Point your browser to http://www.microsoft.com/downloads and search for MDAC. For more info about MDAC, see MSKB 190463. For ODBC drivers for other databases, consult the database vendor.

Access Newsgroups

As you can see in Table A-1, there are quite a few newsgroups devoted to various aspects of Microsoft Access. You’ll generally get better results if you search or post questions in the appropriate group. Comp.databases.msaccess is the only general-purpose group, although microsoft.public.access.gettingstarted is also a great place to post newbie or non-specific questions. The most popular groups are those devoted to forms and form coding (i.e., VB code for forms), queries, and reports. To find these newsgroups, go to http://www.google.com, click the Groups link, and type the newsgroup name in the box and click the Search Groups button.

Table A-1. Alphabetical list of Access newsgroups

comp.databases.ms-access

microsoft.public.access.3rdpartyusrgrp

microsoft.public.access.activexcontrol

microsoft.public.access.commandbarsui

microsoft.public.access.conversion

microsoft.public.access.developers.toolkitode

microsoft.public.access.devtoolkits

microsoft.public.access.externaldata

microsoft.public.access.forms

microsoft.public.access.formscoding

microsoft.public.access.gettingstarted

comp.databases.ms-access

microsoft.public.access.internet

microsoft.public.access.interopoledde

microsoft.public.access.macros

microsoft.public.access.modulesdaovba

microsoft.public.access.multiuser

microsoft.public.access.odbcclientsvr

microsoft.public.access.queries

microsoft.public.access.replication

microsoft.public.access.reports

microsoft.public.access.security

microsoft.public.access.setupconfig

microsoft.public.access.tablesdbdesign

Visual Basic Functions

Programmers use functions and statements the way carpenters use hammers and nails. Visual Basic has nearly 150 functions that you can use in expressions or code. It behooves you to become familiar with these off-the-shelf power tools. If you’re writing code, you should also familiarize yourself with Visual Basic statements, which are listed in Access Help. (Click the Help button, then the Contents tab, then open Visual Basic Language Reference → Statements.) Statements can’t be used in expressions because they don’t return a value, but they do useful stuff, such as writing to a file or changing the current directory.

In addition to these built-in functions, every menu and toolbar command can be run from VB code using the RunCommand method. For example, you can perform the equivalent of View → Zoom → Zoom 100% by calling RunCommand with the acCmdZoom100 constant, like this: DoCmd.RunCommand acCmdZoom100. (To find the constant you need, search for “RunCommand” in VB Help and click the acCommand link or the RunCommand Method Constants item. )

In the following tables (Table A-2, A-3, A-4, A-5, A-6, A-7, A-8, A-9, A-10, through A-11) VB functions are grouped by category. The lists are mostly alphabetical, but occasionally we group related functions. Once you find the function you need, look it up in VB Help for details about its arguments and usage. The 10 categories that we use are:

  • String manipulation and character functions

  • Math functions

  • Date and time functions

  • Data type conversion and formatting functions

  • Files, directories, and environment functions

  • Tests and conditional expressions

  • Domain aggregate functions (those that operate on sets of records)

  • Interactive and process control functions

  • Accounting and financial functions

  • Other functions for use in Visual Basic code

Table A-2. String manipulation and character functions

Function

Description

Asc

Returns ASCII character code of first character in string, e.g., Asc("A") = 65

AscB

Returns first byte of binary data contained in string

AscW

Returns unicode character code of first character in string

Chr

Returns string corresponding to character code of argument, e.g., Chr(65) = "A"

ChrB

Returns first byte of binary data corresponding to character code

ChrW

Returns unicode character corresponding to character code of argument

InStr

Finds position of first occurrence of substring within a given string

InStrB

Used with binary data, returns byte position of substring within a given string

InStrRev

Finds position of last occurrence of substring within a given string

Lcase

Returns lowercase version of string

Ucase

Returns uppercase version of string

Len

Returns number of characters in string

LenB

Returns number of bytes in string

Replace

Replaces some or all occurrences of substring in a string with another substring

Left

Returns leftmost character(s) from string

LeftB

Returns leftmost bytes

Mid

Returns middle character(s) from string

MidB

Returns middle bytes

Right

Returns rightmost character(s) from string

RightB

Returns rightmost bytes

Trim

Trims trailing and leading spaces from string

LTrim

Trims leading spaces from string

RTrim

Trims trailing spaces from string

Space

Returns a string consisting of x number of spaces

Split

Splits a string into substrings based on a delimiter. Returns an array.

StrConv

Performs various case and character set related conversions

StrComp

Compares two strings using alphabetical or other order

String

Returns a string consisting of x number of repeating characters

StrReverse

Reverses the characters in a string

Table A-3. Math functions

Function

Description

Abs

Returns absolute value

Atn

Returns arctangent

Cos

Returns cosine

Exp

Returns inverse of natural logarithm, e.g., Exp(x) = ex

Fix

Returns integer portion by truncation, e.g., Fix(8.3) = 8, Fix(-8.3) = -8

Int

Returns greatest integer less than or equal to x (a.k.a. floor function), e.g., Int(8.3) = 8, Int(-8.3) = -9

Log

Returns natural logarithm

Partition

Partitions a range into intervals, returning the range label for the interval into which its argument falls

Rnd

Returns a random number between 0 and 1

Round

Rounds a number to specified number of decimal places

Sgn

Returns the sign of the number (negative, positive, zero)

Sin

Returns sine

Sqr

Returns square root

Tan

Returns tangent

Table A-4. Date and time functions

Function

Description

Date

Returns current date

Now

Returns current date and time

Time

Returns current time

DateAdd

Adds or subtracts various intervals of time (days, months, years, etc.) to a given date

DateDiff

Computes the number of time intervals (days, months, years, etc.) between two dates

DatePart

Returns an integer value representing some part of a date, e.g., DatePart("m", #2004-09-30#) = 9

DateSerial

Constructs a date value from year, month, and day values, e.g., DateSerial(2004,9,30)

TimeSerial

Constructs a time value for hour, minute, and second values

Day

Description Day Returns day of the month for a given date, e.g., Day(#2004-09-22#) = 22

Weekday

Returns day of the week for a given date, expressed in range (1-7); default treats Sunday as first day of week, but this can be modified

Month

Returns month of the year for a given date, expressed in range (1-12)

Year

Returns year for a given date, e.g., Year(#2004-09-11#) = 2004

Hour

Returns hour of the day, expressed in range (0-23), e.g., Hour("September 22, 2003 3:11 pm") = 15

Minute

Returns minute of the hour, expressed in range, e.g., (0-59) Minute("September 22, 2003 3:11 pm") = 11

Second

Returns second of the minute, expressed in range (0-59)

MonthName

Returns name of month as string for numeric month, e.g., MonthName(1) = "January"

WeekdayName

Returns name of day of week for numeric value; WeekdayName(1) = "Sunday" by default, but you can set a different first day of week

Table A-5. Data type conversion and formatting functions

Function

Description

CBool

Coerces expression to Boolean data type

CByte

Coerces number (0-255) to Byte data type

CCur

Coerces number to Currency data type

CDate

Coerces date expressions and date strings to Date data type

DateValue

Converts date expressions and date strings to Variant (Date) data type

TimeValue

Converts time expressions and time strings to Variant (Date) data type

CDbl

Coerces numbers to Double data type

CDec

Coerces numbers to Decimal data type

CInt

Coerces numbers to Integer data type, rounding if necessary

CLng

Coerces numbers to Long data type, rounding if necessary

CStr

Converts dates, booleans, numbers, etc. to string

Str

Converts number to numeral string, e.g., Str(7) = "7"

Val

Converts numeral string to number, e.g., Val("7") = 7

FormatCurrency

Formats number or numeric string to currency, with various display options; returns a string

FormatDateTime

Formats date or date string as date, with various display options; returns a string

FormatNumber

Formats number or numeric string as number, with various display options; returns a string

FormatPercent

Formats number or numeric string as percent, with various display options, e.g., FormatPercent(.15) = 15.00%; returns a string

Hex

Returns a string representing the hex value of a number, e.g., Hex(255) = "FF"

Oct

Returns a variant representing the octal value of a number, e.g., Oct(255) = "377"

Table A-6. Files, directories, and environment functions

Function

Description

CurDir

Returns full path of current working directory

CurrentUser

Returns username of user currently logged into database (not a VB function…but it’s useful, and we refer to it in the text)

Dir

Searches for files or directories matching a given string and attribute set; returns first match

Environ

Returns value of a given environment variable

EOF

Tests file for end of file condition

FileAttr

Returns long value representing mode in which file was opened

FileDateTime

Returns last modified date of file

FileLen

Returns length of file in bytes; use LOF if file is open for editing

LOF

Returns length of file in bytes, for a file that is currently open

FreeFile

Returns integer value representing next file number available for use

GetAttr

Retrieves system attributes of a file or directory

Input

Reads characters from a file; returns a string.

InputB

Reads byte data from a file

Loc

Returns the current read/write position within an open file

Seek

Returns the next read/write position within an open file

Table A-7. Tests and conditional expressions

Function

Description

Choose

Selects from a list of choices based on value of an index expression that ranges from 1 to the number of choices. For example, Choose(index, "First", "Second", "Third") equals “Second” when index = 2.

IIf

Stands for immediate If; Selects from two choices based on a Boolean expression. If the expression is true, returns the first choice; if the expression is false, returns second choice (e.g., IIf([accountBalance] <= 0, "You're broke", "You've got cash")).

Switch

Selects from a list of choices based on a list of conditions, returning the first choice whose condition is true, e.g., Switch([accountBalance] <= 0, "You're broke", [accountBalance] < $250, "You're poor", [accountBalance] >= $250, "Yippee!").

IsDate

Tests whether an expression can be interpreted as a date.

IsError

Tests whether an expression returns an error.

IsNull

Tests whether an expression has no value.

IsNumeric

Tests whether an expression can be interpreted as a number.

Table A-8. Domain aggregate functions

Function

Description

DAvg

Returns average of values.

DCount

Returns number of records.

DLookup

Returns value of first record that meets criteria.

DFirst, DLast

Despite the names, not very useful: returns the first (or last) record based on the order in which the records are stored, which is usually meaningless. According to Help, they should be used when you want a “random” record.

DMin, DMax

Returns minimum and maximum values.

DStDev, DStDevP

Returns standard deviation (sample) and estimated standard deviation (population).

DSum

Returns sum of values.

DVar, DVarP

Returns variance (sample) and estimated variance (population).

Table A-9. Interactive and process control

Function

Description

DoEvents

Yields process control, allowing Windows to process events such as key presses or mouse clicks in the middle of a long computation. Does not return until all events in the queue are processed.

InputBox

Displays a prompt that accepts user input in a text box.

MsgBox

Displays a message prompt with various button options (Okay/Cancel, Yes/No/Cancel, etc.).

Shell

Runs an executable program from code.

Timer

Returns elapsed time.

Table A-10. Accounting and financial functions

Function

Description

DDB

Returns depreciation (double-declining balance)

FV

Returns future value of an annuity

Ipmt

Returns interest payment of an annuity

IRR

Returns internal rate of return

MIRR

Returns modified internal rate of return

NPer

Returns number of periods for an annuity

Pmt

Returns payment for an annuity

PPmt

Returns principal payment for an annuity

PV

Returns present value of an annuity

Rate

Returns interest rate per period for an annuity

SLN

Returns depreciation (straight-line)

SYD

Returns depreciation (sum-of-year’s digits)

Table A-11. Other functions for use in Visual Basic code

Function

Description

Array

Creates an array from a list of values—but returns a Variant type, not a true array

CallByName

Invokes a method on an object using a string name

Command

Command-line arguments

CreateObject

Creates an ActiveX object, based on object class

GetObject

Creates an ActiveX object, based on path to component

CVErr

Returns a custom error number

Error

Returns error message that corresponds to a given error number

Filter

Filters an array of strings based on criteria

GetAllSettings

Returns windows Registry settings for an application

GetSetting

Returns windows Registry setting for a specific key and application

IMEStatus

Current Input Method Editor mode for East Asian languages

IsArray

Tests for array type

IsEmpty

Tests whether a variable has been initialized

IsMissing

Tests whether an optional argument has been supplied to a procedure

IsObject

Tests whether an identifier refers to an object

Join

Concatenates an array of strings

LBound

Finds start value for range of an array index

UBound

Finds end value for range of an array index

MacID

Macintosh constants function

MacScript

Runs an Apple script

QBColor

Converts color codes (0-15) representing standard colors into RGB values

RGB

Constructs RGB value from Red, Green, and Blue values (0-255)

Spc

Returns number of spaces to insert in Print statement

Tab

Specifies tab position for Print statement

TypeName

Returns a string representing the data type of a variable

VarType

Returns an integer constant representing the data type of a variable

Macro Actions

Access has over 50 different actions that can be specified in a macro. (In addition to these built-in actions, every menu and toolbar command can be run from a macro using the RunCommand action.) In the following tables (Tables A-12, A-13, A-14, A-15, A-16, through A-17), the actions are grouped by category. The lists are mostly alphabetical, but occasionally we group related actions. Once you find the action you need, look it up in Access Help for details about its arguments and usage. (An easy way to do this is to select the action in the macro design window and press F1.)

The six categories are:

  • Work with database objects

  • Work with data

  • Import, export, and linking

  • User interface

  • Printing, email, and external applications

  • Macro programming

Table A-12. Work with database objects

Action

Description

Close

Closes an open object (query, form, and so on).

DeleteObject

Deletes an object (query, form, and so on).

OpenDataAccessPage

Opens a data access page in page view or design view.

OpenDiagram

Opens a database diagram in design view.

OpenForm

Opens a form in any of various views. You can apply filters, where conditions, data entry, and window modes.

OpenModule

Opens a Visual Basic module to a specific procedure.

OpenQuery

Runs a query, or opens it in design view or print preview.

OpenReport

Opens a report in any of various views. You can apply filters and where conditions.

OpenStoredProcedure

Opens a stored procedure in any of various views.

OpenTable

Opens a table in any of various views. You can set data mode.

OpenView

Opens a view in any of various views. You can set data mode.

Quit

Quits Microsoft Access.

Rename

Renames a database object. (Note: You can’t rename an open object.)

Save

Saves the specified object (form, query, etc.), or the active object if none is specified.

SelectObject

Selects the specified object (form, query, etc.), making it visible and enabling subsequent actions such as Maximize, GoToControl, and so on.

Table A-13. Work with data

Action

Description

ApplyFilter

Applies a filter, a query, or an SQL WHERE clause to a table, form, or report.

FindNext

Finds the next record; used after FindRecord.

FindRecord

Finds a record matching certain criteria.

GoToRecord

Moves to a specific record (by record number) in a set of records, or moves to Previous, Next, First, Last, New or (using offset) jumps back by N or jumps forward by N.

RepaintObject

Forces pending screen updates on an object (form, datasheet, etc.), e.g., shows values that have been set in a macro but haven’t yet appeared.

Requery

Requeries the specified control (or the active object, if no control is specified). This updates the result set, taking into account new, changed, or deleted records.

RunSQL

Runs an SQL statement. You can’t run select or crosstab queries this way (use OpenQuery), only action or data definition queries. SQL statement is limited to 256 characters.

ShowAllRecords

Removes any filters from the active table, query, or form.

Table A-14. Import, export, and linking

Action

Description

CopyObject

Copies an object (query, form, and so on) from one MDB to another.

OutputTo

Exports data in table, query, and so on, to specified format (HTML, text, RTF, ASP, DAP, IIS, Excel ’98). You can autostart an appropriate application for the output file. Note: Use TransferSpreadsheet for current Excel format; use TransferText to include an import/export specification.

TransferDatabase

Imports, exports, or links database objects between two databases.

TransferSpreadsheet

Imports, exports, or links an Excel or 1-2-3 worksheet.

TransferText

Imports, exports, or links a text file.

Table A-15. User interface

Action

Description

AddMenu

Creates custom/global menus (deprecated).

SetMenuItem

Sets state (enabled/disabled, and so on) of items on menus created with AddMenu (deprecated).

Beep

Returns the system beep

Echo

Turns echo off to hide macro output while it runs (does not hide message boxes or errors).

GoToControl

Moves the cursor (sets focus) to a particular field or control on a datasheet or form.

GoToPage

Moves the cursor to the first control on a specific page, in a form with multiple pages.

Hourglass

Displays hourglass while macro is running.

Maximize

Maximizes the active window.

Minimize

Minimizes the active window.

MoveSize

Moves and/or resizes the active window.

MsgBox

Displays a warning or informational message box.

Restore

Restores a window that has been minimized or maximized. Note: Use the SelectObject action to specify the window.

SetWarnings

Enables or disables system messages (typically used to disable confirmation messages for action queries). Messages are turned back on automatically when macro finishes.

ShowToolbar

Displays or hides a built-in toolbar or a custom toolbar.

Table A-16. Printing, email, and external applications

Action

Description

PrintOut

Prints a report, datasheet, and so on, specifying page range, number of copies, etc.

RunApp

Runs an external application, such as Word or FTP.

SendObject

Sends database object (form, report, and so on) in the body of an email message. You can specify various output formats for objects (XLS, TXT, HTML, RTF), subject line, message, and so on.

Table A-17. Macro programming

Action

Description

CancelEvent

Cancels the event that triggered the macro.

RunCode

Calls a Visual Basic function. Note: You must include parentheses, even if there are no arguments, like this: myFunction().

RunCommand

Runs a built-in Microsoft Access command (e.g., from a menu or toolbar).

RunMacro

Runs a macro. You can specify the number of times to repeat, or that it repeats until a condition is satisfied.

SendKeys

Types keystrokes as if input by user (e.g., to fill in a dialog box or send to an external application). Maximum of 256 characters. Timing is unreliable.

SetValue

Sets value of a field, control, or property of a form, report, or control. Note: You must not begin your expression with an equals sign.

StopAllMacros

Stops all macros currently running.

StopMacro

Stops this macro.

Note

There are over 15 events that are specific to PivotTables and PivotCharts. Technically, these are not Access events; they’re part of the Office Web Components library. But you will see them listed at the bottom of the Event tab of a form or report. To get more info on these pivot events, place the cursor in that event field and press F1.

Events

Forms include about 45 different event hooks (Open, Close, AfterUpdate, and so on), each of which allows you to run your own code or macro at a certain point in Access’s program flow. For example, every time a form is opened, Access sees if any code has been added to the form’s Open event, and if it has, it runs it. Writing code in event procedures is a powerful way to customize the way Access behaves.

In the following tables (Tables A-18, A-19, A-20, A-21, through A-22), events are grouped by category. The lists are mostly alphabetical, but occasionally we’ll group related events. Note that only forms allow you to use control events; there are no events for controls on reports. The tables also indicate whether an event can be canceled (usually by setting a Cancel parameter equal to True), returning control to the user.

Once you find the event you need, look it up in Access Help for details about its usage. If you need precise information about the order of events, search for “order of events” or look under Programming in Access. The five categories that we use are:

  • Window and focus events

  • Data events

  • Keyboard and mouse events

  • Report layout and printing events

  • Other events

Table A-18. Window and focus events

Event

Applies to

Description

Cancel?

Open

form, report

Form/report is about to open.

Y

Close

form, report

Form/report is about to close.

 

Load

form

Form’s record source is about to load.

 

Unload

form

Form’s record source is about to unload.

Y

Resize

form

Form window is about to resize.

 

Activate

form, report

Form/report window is about to become the active window.

 

Deactivate

form, report

A different Access window is about to become active. This event doesn’t fire if some other application becomes active.

 

Enter

controls

Control is about to receive focus from another control on the same form.

 

Exit

controls

Control is about to lose focus to another control on the same form.

Y

GotFocus

form, controls

Control is about to receive focus. A form can get focus only if it does not contain any visible, enabled controls.

 

LostFocus

form, controls

Control is about to lose focus. A form can lose focus only if it does not contain any visible, enabled controls.

 
Table A-19. Data events

Event

Applies to

Description

Cancel?

BeforeInsert

form

New record is about to be created.

Y

AfterInsert

form

New record has just been created.

 

BeforeUpdate

form, controls

Data is about to be updated (applies to new/existing records).

Y

AfterUpdate

form, controls

Data has just been updated (applies to new/existing records).

 

Change

text box, combo box, tab

User types into a text or combo box, or moves between pages in a tab control.

 

Current

form

Some record is about to become the current record. This event fires when a form is first opened, when the user navigates to a different record, or when data is refreshed or requeried.

 

Delete

form

A record is about to be deleted. If multiple records are selected for deletion, this event fires once for each record.

Y

Dirty

form, text box, combo box

User is making a change in a bound form or control—typing in a text box, clicking in a combo box, and so on—which would cause the underlying field or record to become "dirty” (edited). (Dirty=unsaved.) Occurs before the change is allowed (and before the Dirty property is set to True). Does not occur for an unbound form or control.

Y

NotInList

combo box

User enters a value that isn’t in the list (and LimitToList property is set to Yes). Cannot be canceled, but Response argument determines whether an error message is displayed.

 

Undo

form, text box, combo box

User is undoing a change in a bound form or control—clicking Undo or pressing the Escape key. Occurs before the change is undone (and before the Dirty property is set to False). Does not occur for an unbound form or control.

Y

Table A-20. Keyboard and mouse events

Event

Applies to

Description

Cancel?

KeyDown KeyPress KeyUp

form, controls

KeyDown occurs when a key is pressed; KeyUp occurs when it is released; KeyPress occurs when a key is pressed and released. Both KeyDown and KeyPress also occur every time a key repeats due to being held down. When they both occur, KeyPress precedes KeyUp. Keystrokes that are attributed to SendKeys actions or statements also trigger these key events. Key events are received by the control that currently has focus, or (if there’s no control available to receive focus) by the form. If the form’s KeyPreview property (on the Event tab) is set to Yes, it will receive all key events before they are sent to the control where they originated.

Y

Click DblClick

form, controls

Click/DblClick occurs when the user clicks/double-clicks the mouse on the control. Forms receive this event if a user clicks/double-clicks the record selector or a blank space in the form that is not within any control or section.

Y

MouseDown MouseMove MouseUp

form, controls

MouseDown occurs when a mouse button is pressed; MouseUp occurs when it is released; MouseMove occurs when the mouse is moved but no button is pressed. Unlike click events, these events tell which button was pressed (1=left and 2=right). The mouse event is received by the control the mouse is over when the mouse button is released, regardless of which control has focus at the time. The form will receive mouse events that occur in the record selector region, and in a region that is outside of any section or control (e.g., around navigation buttons).

Y

Table A-21. Report layout and printing events

Event

Applies to

Description

Cancel?

Format

report sections

A report section is about to be formatted for printing or previewing.

Y

NoData

report

A report that has no data is about to be printed or previewed.

Y

Page

report

A report page has been formatted and is about to be printed or previewed.

 

Print

report sections

A report section has been formatted and is about to be printed or previewed.

Y

Retreat

report sections

A report section that cannot be formatted and printed in a single pass is about to get a second pass.

 
Table A-22. Other events

Event

Applies to

Description

Cancel?

Timer

form

Fires at regular intervals specified by the form’s TimerInterval property (on the Event tab). The interval is specified in milliseconds. If TimerInterval is 0, the event does not fire.

 

Error

form, report

Fires when a runtime error occurs. This event includes Access and Jet errors, but not Visual Basic errors.

 

BeforeDelConfirm

form

Fires when the delete confirm dialog box is about to be displayed.

Y

AfterDelConfirm

form

Fires when the delete confirm dialog box has just been responded to.

 

ApplyFilter

form

Fires when the user applies or removes a filter using Apply Filter, Remove Filter, or Filter By Selection.

Y

Filter

form

Fires when the user begins to create a filter using Filter By Form or Advanced Filter/Sort.

Y

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset