Part III: More-Advanced Access Techniques
690
The TimerInterval property is set to 200 through the Property Sheet for the form, meaning
that this code will execute every 200 milliseconds. Set it to a longer interval to slow down the
animation.
Notice that the plane’s position is reset as soon as the left margin of the plane exceeds 9,000 twips.
Using SQL for a faster refresh
You can generate faster combo-box refreshes on a form by making the control’s row source a SQL
statement instead of a query name. Complete the following steps:
- Generate the query using the standard procedure.
- Make the query the control’s RowSource property and make sure the combo box is cor-
rectly populated.
- When everything works correctly, display the query in Design view and select SQL from
the View menu.
- Cut and paste the SQL statement into the combo box’s RowSource property.
Selecting data for overtyping
When users edit existing data in a form, they usually prefer to type over existing data without hav-
ing to first select the existing data. The following function when triggered by each control’s
GoFocus event has this effect:
Function SelectAll()
‘Set the cursor to the beginning of the field.
Screen.ActiveControl.SelStart = 0
‘Select all positions up to the last.
‘This will make a reversed image, which will be easier to see.
Screen.ActiveControl.SelLength = _
Len(Screen.ActiveControl)
End Function
Toggling properties with Not
A handy way to toggle properties that take Boolean values, such as the Visible property, is to
use the Not operator. For example, the following VB statement toggles the object’s Visible
property, regardless of the actual value of the property:
Object.Visible = Not Object.Visible
For example, if Visible is True, its value is set to False, hiding the object. By using the Not
operator, you don’t have to test for the current value of the property.
Chapter19.accdb contains a simple form demonstrating this capability. frmFlashingLabel
contains two label controls (lblRed and lblBlue) placed on top of one another. lblRed’s