Access Cookbook - Ken Getz [280]
To add your own images to the navigation buttons on a DAP, follow these steps (or open 13-01.mdb to see the completed sample):
Create the images you want to use for the navigation buttons. The Previous and Next buttons for our sample page are shown in Figure 13-1.
Figure 13-1. Active and inactive versions of the Previous and Next buttons
Create a DAP and add whatever controls you'd like. Once you've added fields from tables or queries, you'll see a default navigation section like the one shown in Figure 13-2.
Figure 13-2. The default navigation section includes several buttons
Eliminate any buttons you don't want. For our simple example, we eliminated all buttons except the Previous and Next buttons. To get rid of a button, either select it and press the Delete key, or right-click the navigation control, select Navigation Buttons from the context menu, and toggle off the buttons you don't want.
Select a navigation button and display its properties sheet.
Find the Src property (in the Other page of the properties sheet). Change the property's value to the name of the image you want displayed, as shown in Figure 13-3. Note that the properties sheet seems to insist on storing the full path to the image, even when it is entered as a relative path.
Figure 13-3. Specify the image you want displayed in the Src property
Repeat Step 5 for each button you need to change.
Test the resulting page. Our sample page looks like Figure 13-4.
Figure 13-4. The look of our page is now consistent with the rest of our intranet
Discussion
All the functionality for a navigation button is contained within the DataSourceControl Office Web Component. The name of the image to use, though, is stored in the HTML source of the page. The component itself checks for the name with the "Inactive" string to adjust the appearance of the button relative to the context.
The properties sheet appears to store a full path to the image. That is, you might type in the following text:
Images\ArrowLeft.tif
But when you leave the property, the value will be adjusted to show a full path and filename:
c:\MyPages\Images\ArrowLeft.tif
Internally, however, the HTML source is storing a relative path. If the path to the page changes but it retains an Images subfolder, the page will not break; the image in the relative path will still be found. (The same can't necessarily be said of your data, of course.)
13.2. Use Labels or Other Controls for Record Navigation
Problem
You don't want to use images for the navigation buttons on your pages; you'd prefer to simply use labels that say "Previous", "Next", and so forth.
Solution
The default navigation images function as they do because each is a member of a particular class. You can use another type of control for navigation by adding the correct class name to the control's ClassName property.
Our solution, found in the Custom Nav Text DAP in the sample database, uses labels to create the look shown in Figure 13-5.
Figure 13-5. This page uses navigation labels instead of images
TIP
In order to try out the sample provided for this section, please see the introduction to this chapter, which describes how you can update the connection information and connect the DAP to the sample database.
To use labels as navigation controls, follow these steps (or open 13-02.MDB to see the completed sample):
Create a new page and add whatever data you'd like.
Delete all navigation control buttons from the navigation section.
Place labels in the navigation control section for each navigation function (First, Previous, Next, Last).
Select the "First" label and view its properties sheet. The ClassName property should read:
MSTheme-Label
Change the ClassName property so that it includes the appropriate class for the first navigation button, msoNavFirst. The ClassName property should now read: