Home  Fees/Services  Access Examples  Tutorials  Access Download  Articles  Search  Contact  Privacy  Links
Custom Database Design Consultants
 
Access Programming Examples
 
Access Example Downloads
Access Form Events Access Event Coding Examples
Form Event Programming
Access VBA Events

 Database Tutorials > Form Event Tutorials > Change Event

                               

After Insert Event
After Update Event
Before Update Event
On Change Event
On Close Example
On Current Event
On DblClick Event
On Error Event
On Exit Event Help
VBA Timer Event
Undo Event Method


On Change Event

Slow opening MS Access forms can annoy the user.
Program activation can sometimes take more than a minute when using a tabbed interface.  We have developed a simple method that often speeds up program activation and form opening by a factor of 10.  The method involves the on change event with a simple technique - use local dummy tables as the record source for forms until the forms are viewed by the user.

Below is the setup of our tabbed interface:

visual basic on change event

There are more forms off to the right side.  The total count of all the form that get opened when the program starts up is about 20, counting the subforms.  This number of forms doesn't slow the database down much when all the tables are local to the front end.

However, when the database is split into a front end/back end arrangement the time for the program to start up increases dramatically.  For this database the total time exceeded one minute.  This slow startup was not satisfactory for the user.

Our solution was simple - create dummy tables for containing no records for most of the forms associated with each tab.  Below is a list of some of the tables in the database:

On Change Form Event Example

The Z_ tables are the dummy tables and you can see the real linked tables for most of them towards the top of the list - these begin with M_.

The image below shows the contents of one of the Z_ tables:

Access Change Event Tabbed Interface

Note that the table contains a single dummy record.  We have found that this works best compared to having no records in the table.

The image below shows that the Record Source for the stabling form is set to the dummy table Z_Stabling. 

VBA Change Event Example

Next we need to show you how and when to switch to the real table.  We change the record source to the real table when the user clicks on the Stabling tab, activating the On Change event:

On Change VB Code

Note that we have defined an Event Procedure associated with the On Change event of the TabCtl0 object.

Below is the code for the On Change event procedure:

Access Database Form Event Change

So, when the user clicks on the Stabling tab the code checks to see if the record source is set to the dummy record source and if so then changes the record source for the form to the real table 'L_Stabling'.

The result of using this technique speeded up the database activation from over a minute down to 8 seconds.

Go here to see more about Select Case statements.

We have many more examples of using tab controls in Access databases.

Contact Information

Event Procedures in MS Access
Microsoft Access 2003 2000 2002(XP) 97 All Windows Versions