Microsoft Access 2010 Bible

(Rick Simeone) #1

Chapter 26: Bulletproofing Access Applications


927


Using AddStartupProperty() is quite easy. You must know the exact property name and data
type of the property before invoking AddStartupProperty(). The following subroutine dem-
onstrates how to set a start-up property with AddStartupProperty():

Sub cmdAddProperty_Click()
Dim iRetVal As Integer
iRetVal = AddStartupProperty(“AppTitle”, dbText,
“Marketing Contact Management”)
iRetVal = AddStartupProperty(“AppIcon”, dbText,
“C:\My Documents\World.ico”)
End Sub

Notice that both the AppTitle and AppIcon properties are string data types (dbText).

Tip
Use the RefreshTitleBar method to see the changes made by setting either the AppTitle or AppIcon
property. The syntax of RefreshTitleBar is simple:


Application.RefreshTitleBar

Getting property values
Getting the value of a property is much easier than setting a property’s value. The GetOption
method returns the value of a property. The syntax of GetOption is as follows:

vRetVal = GetOption(PropertyName)

where vRetVal is a variant and PropertyName is the name of a property in Table 26.4. The fol-
lowing code fragment shows how to use the GetOption method to read an option property:

Dim vRetVal As Variant
‘ Get the current setting.
vRetVal = Application.GetOption(“Project Name”)

A variant is used to capture the return value because of the different data types used for start-up
properties. Also, a property that has not yet been set may be null, and the variant is the only type
of variable that can accept null values without error.

Protecting your database
As has already been explained, bulletproofing an application means safeguarding the application’s
data. Ideally, you want to prevent errors from occurring, not simply be able to identify when errors
occur and recover from them.

The next few sections discuss a number of techniques you can use in an attempt to minimize the
ability of the user to make mistakes. I’ll also talk a little about safeguarding the Access environ-
ment, so that user can’t go “behind the scenes” and introduce problems.
Free download pdf