Splash Screen Forms

One easy way to get started with forms is by creating a splash screen. A splash screen is a form that appears before another, more interactive form appears. Splash screens often state what an application does or who created it. You can easily control how long this form stays visible. Figure 5-1 shows a sample splash screen from the companion CD, which you can adapt to your own purposes.

click to view at full size.

Figure 5-1. A sample splash screen.

Creating a Splash Screen

You can start by creating a tiled background. You do so by setting two form properties while the form is open in Design view. First, you set the form's Picture property (on the Format page of the Property sheet) to the path and filename for the image. You can use a bitmap in .bmp, .ico, .dib, .wmf, or .emf format. Access can also use other graphic file formats for which you have filters installed. (Rerun the Setup program if you need to install additional filters.) Images that contain gray or other muted colors work best for backgrounds because they make your foreground images and text look more prominent. Second, you change the form's Picture Tiling property to Yes. (It is No by default.)

Next, you can add a foreground image by choosing Picture from the Insert menu. You can also add an Image control to the form. Either method opens the Insert Picture dialog box, where you can select an image to add. Clicking OK automatically sets the image's Picture property. Access lets you programmatically set the Picture property with Microsoft Visual Basic for Applications (VBA) so you can construct the look of a form dynamically in response to user input (such as a text box entry) or environmental factors (such as a user's security ID). You can position and size the image and use the special effects created by various Size Mode property settings. The property accepts three values: Clip, Stretch, and Zoom.

You complete the splash screen by adding one or more Label controls. You can use VBA to set properties for the Label controls at run time. This lets you dynamically format a splash screen's text.

You can set a splash screen to open automatically by choosing Startup from the Tools menu and selecting the splash screen's form name in the Display Form/Page drop-down list in the Startup dialog box. You can also hide the Database window when an application opens by deselecting the Display Database Window check box in the Startup dialog box. Click OK to save your choices.

Controlling Display Duration

The following pair of event procedures displays a splash screen for 10 seconds. (To get to the VBA behind a form, right-click on the form, choose Build Event from the shortcut menu, and then select Code Builder in the Choose Builder dialog box and click OK.) The Form_Open event procedure sets the form's TimerInterval property value to 10000 (10 seconds; the interval is in milliseconds). The Form_Timer event procedure closes the form. Notice that Form_Open uses the Me keyword to denote the form. You could replace "frmSplashTimer" with Me.Name in Form_Timer; the Me naming convention is more robust because it lets you change a form's name without revising the code.

Private Sub Form_Open(Cancel As Integer)     Me.TimerInterval = 10000 End Sub Private Sub Form_Timer()     DoCmd.Close acForm, "frmSplashTimer" End Sub 



Programming Microsoft Access 2000
Programming Microsoft Access 2000 (Microsoft Programming Series)
ISBN: 0735605009
EAN: 2147483647
Year: 1998
Pages: 97
Authors: Rick Dobson

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net