Quick Tip: Custom icons can make new apps friendly and familiar

Help users quickly acclimate themselves to a new application or report displaying custom icons that they can quickly relate to the applications purpose or to their company.

Familiarity doesn't always breed contempt. Anything that makes your users feel more at home and at ease with a new application is a bonus. One way to help users quickly acclimate themselves to a new application or report is to display custom icons that users can quickly relate to the application's purpose or to their company.

Even if familiarity isn't an issue, a custom icon that represents the application or client's business looks impressive and can present the application—and you—in a positive, professional manner. Fortunately, changing the generic Access icon is as simple as changing a property. There's no need to tell your users and clients how easy it was to personalize their application to the company's image and flavor. Just let them think you're a genius.

In this article, we'll look at a new startup option in Access 2002 that lets you specify the icon Access displays on the Windows taskbar. Our sample file uses Access 2002 and Windows 2002. If any of your systems use Windows 2000, be sure to enable Active Directory. If you don't, the icon property will have no effect. Note that Windows NT doesn't support this feature.

How to specify the icon
Custom icons offer the advantages of easy recognition and convenience, especially if users consistently work with several apps open besides Access. Users will probably adapt to the default Microsoft Access icon—the infamous Access key icon—but a company logo or some other graphic that users readily identify with could be a better choice. At the very least, it's a bit of name recognition for the user and requires no additional time for you during the development stage.

Beginning with Access 2002, you can display a custom icon to represent forms, reports, and even Access itself on the taskbar. As a result, you can control what users see: a company logo, a simple graphic, or even a departmental- or employee-based icon.

Let's try a quick example using Northwind, the sample database that comes with Access. First, choose Startup from the Tools menu to display the Startup dialog box. Using the Browse button to the right of the Application Icon control, select an icon file (.ico or .cur), such as the custom icon h.ico, shown in Figure A, which you'll be working with later in this article.

Figure A

Access will display the specified icon file on the taskbar to represent the open Access application. If you also want the icon to represent open forms and reports, select the Use As Form And Report Icon check box in the Startup dialog box, as shown in Figure B. Click OK to close the dialog box.

Figure B
Specify a custom icon in the startup options.

If you followed our example and actually reset the icon option in your copy of Northwind, we recommend you reverse that change before you continue. Otherwise, your copy of Northwind will continue to display the custom icon.

Access 2002 displays multiple icons—one for each open object, as shown in Figure C. Users can simply select an object from the list to return focus to that object. You can change this behavior by choosing Options from the Tools menu and clicking the View tab. Next, deselect the Windows In Taskbar check box and click OK. Access will then display only the icon on the taskbar, and clicking it will return users to the active object. It's more limiting, but for some, it might be less confusing.

Figure C
By default, the Access icon lists the open objects.

Setting the property
Although knowing how to manually manipulate this property might be useful for the occasional tweak to a single system, you'll probably prefer to control it programmatically. Consider storing this icon in the same folder as the application for the sake of convenience, and make sure it travels with the application if users aren't working with a networked copy.

As I mentioned, the icon property is a startup option, and these properties belong to the Database object, a member of the Data Access Object library (DAO). However, these properties are defined by Access, so you must programmatically create the property if it hasn't been previously set. What that means is you must add the property to the Database object's Properties collection. Don't worry, though—it sounds more complicated than it actually is. (In an .adp file, these properties belong to the CurrentProject object.)

Keep in mind as you review the following code samples that the VBA startup property names don't match their corresponding options in the Startup dialog box. Table A lists the property names for each option.
Table A
Startup Option VBA Counterpart DAO Data Type Constant
Application Title AppTitle dbText
Application Icon Applcon dbText
Display Form/Page StartupForm dbText
Display Database Window StartupShowDBWindow dbBoolean
Display Status Bar StartupShowStatusBar dbBoolean
Menu Bar StartupMenuBar dbText
Shortcut Menu Bar StartupShortcutMenuBar dbText
Allow Full Menus AllowFullMenus dbBoolean
Allow Default Shortcut Menus AllowShortcutMenus dbBoolean
Allow Built-In Toolbars AllowBuiltInToolbars dbBoolean
Allow Toolbar/Menu Changes AllowToolbarChanges dbBoolean
Allow Viewing Code After Error AllowBreakIntoCode dbBoolean
Use Access Special Keys AllowSpecialKeys dbBoolean
Table A: VBA startup properties

Before going any further, you should know a little more about the example you'll be following. To keep things simple, the file contains only a few objects from Northwind—the Employees form, the Alphabetical List of Products report, and the tables and queries necessary to support them: the Categories, Products, Suppliers, and Employees tables and the Alphabetical List of Products query.

The simple form in Figure D, named frmStartup, acts as a startup form; however, you can use any form you like. You must set that particular startup property manually. To do so, choose Startup from the Tools menu, select frmStartup (or your startup form) from the Display Form/Page control's drop-down list, and click OK. The example form opens the Employees form and the Alphabetical List of Products report as a matter of convenience. It isn't necessary that your startup form do so for the code to work.

Figure D
Create a startup form.

The function procedure in Listing A is a generic procedure for setting startup properties. You can use it to set any of the setup properties listed in Table A. If you're working in an Access project (.adp), use the simpler subprocedure in Listing B. (Keep in mind that the .adp version contains no error handling, nor is it a Boolean function.) Enter either procedure in a standard module and save it.

Next, open frmStartup's module and enter the event procedure shown in Listing C. Be sure to modify the name of the icon appropriately and list the file's entire pathname. Save your changes, close the form, and then close the application itself.

Where's the DAO Library?
In Microsoft Access, the Application object's CurrentDb method establishes a hidden reference to the Microsoft DAO 3.6 Object Library, so there's no need to explicitly set a reference to it. However, to use CurrentDb in an Access project (.adp), you must set an explicit reference to the DAO 3.6 Object Library. If your application has an explicit reference to the DAO library, you can substitute the integer 10 in the startup form's Load event statement:
boo = SetStartupOptions("AppIcon", 10, "C:\A\TechRepublic\Icons\h.ico")
with the more readable DAO constant, dbText.

How it works
Next time you open the application, the startup form will execute SetStartupOptions. To demonstrate, go ahead and open it now. If the AppIcon property doesn't yet exist in the Database object's collection, the function will add it, specifying the icon named h.ico (or the icon you specified). The first time the property is set, SetStartupOptions returns True. As a result, the calling sub (in the startup form) also sets the Use As Form And Report Icon option (see Figure A). The process is so fast that you'll never see anything but the custom icon (Figure E).

Figure E
The procedure displays your custom icon on the Windows taskbar.

Because the whole process is attached to the startup form's Load event, the application will attempt to set the property each time you launch it. That's one of the by-products of the sample file's arrangement, and it may not suit your needs. For our purposes, it was the simplest route; you may choose another. If the property already exists, the SetStartupOptions function returns False and, subsequently, at least a few of the statements are skipped.

Worth noting
When distributing an icon, make sure it's in the public domain or that you or the client owns the copyright. If you create your own, remember that the icons are very small and that details will be lost or could obscure the icon's message. Keep the lines and colors basic and simple.

Startup options can be bypassed by holding down the [Shift] key while loading the database (unless the application is a runtime version). To block this potential bypass, set the AllowByPassKey database property to False. Attach the following code to a closing event in your application to set the property at the end of each session:
Call SetStartupOptions("AllowByPassKey", dbBoolean, False)

This statement is a finishing touch; don't add it until the application is thoroughly debugged and ready to be distributed. If you should run into trouble, use SetStartupOptions to set the property to True so you can properly debug the problem.

The custom icon used in this article was made with Active ICONStudio 5.0, by Caltrox Software Systems. If you're shopping for icon software, you might also take a look at Clic.

Susan Sales Harkins is an independent consultant and the author of several articles and books on database and Web technologies. Her most recent books are SQL: Access to SQL Server (Apress), Mastering Dreamweaver MX Databases (Sybex), and Absolute Beginner's Guide to Microsoft Access 2002 (Que).

About Susan Harkins

Susan Sales Harkins is an IT consultant, specializing in desktop solutions. Previously, she was editor in chief for The Cobb Group, the world's largest publisher of technical journals.

Editor's Picks

Free Newsletters, In your Inbox