Skip to Main Content
Integrating Excel and Access
book

Integrating Excel and Access

by Michael Schmalz
November 2005
Intermediate to advanced content levelIntermediate to advanced
236 pages
6h 32m
English
O'Reilly Media, Inc.
Content preview from Integrating Excel and Access

Using Events

Events are some of the most useful things you can use to control a user interface. Events happen at the form level and at the individual control level. At the form and control levels, there are some key events I find very useful, which I outline here.

OnCurrent

The OnCurrent event runs each time the focus moves between records. There are several reasons to use this. First, based on values in a record, you might want to enable certain buttons and disable others. You can control this by setting the Enabled property of the command buttons based on If...Then statements or Select...Case statements. You might also want to perform some type of calculation or pull some data from another table based on what is in a current record. All of this can be done automatically using the OnCurrent event.

BeforeUpdate/AfterUpdate

The BeforeUpdate and AfterUpdate events are best used on text boxes, combo boxes, etc. The main difference between them is that BeforeUpdate fires prior to making the change to the field, and AfterUpdate fires after the change has been made to the field. Use BeforeUpdate when performing data validation. If the data is not what you expected, take actions to ensure proper data. Depending on what you are trying to do, you might want to test both to make sure that you use the correct one. If you use these events on a control connected to data (and the name of the field is different from the name of the control), when the BeforeUpdate event fires, the text box holds ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Business solutions Automating Microsoft® Access with VBA

Business solutions Automating Microsoft® Access with VBA

Susan Sales Harkins, Mike Gunderloy
Microsoft® Office Excel 2003 Programming Inside Out

Microsoft® Office Excel 2003 Programming Inside Out

Curtis Frye, Wayne S. Freeze, Felicia K. Buckingham

Publisher Resources

ISBN: 0596009739Supplemental ContentErrata Page