Вы находитесь на странице: 1из 4

Creating a Microsoft Access Splash Screen:

Software applications often display a splash screen when launching. With Microsoft
Access you will often see the splash screen displayed before being presented with the
database switchboard or similar form.

The splash screen in Microsoft Access will usually display a logo of the company that
has created the database application, contact details of the person responsible for the
administration and maintenance of the database or will sometimes display other useful
information or tips associated with the database.

We can use the screen to display randomly selected tips or help topics, providing the tip
will benefit the end user. To avoid irritating the user, we should also provide them with
the option of not having the splash screen appear in the future.

This tutorial details:

How to create and add a splash screen to your Access Database

1. In the database window choose Forms from the Objects. Double-click Create
form in Design View
2. Open the Properties dialog box for the form (View » Properties) and on the
Format tab set the following properties:

Property Value
Scroll Bars Neither
Record Selectors No
Navigation Buttons No
Dividing Lines No
Auto Center Yes
Border Style Dialog
Control Box No
Min Max Buttons None
Close Button No
3. Choose File » Save and save the form as frmSplashScreen

The form should look similar to below. We will now want to start modifying this
and making it look more presentable:
4. Change back to form design view. Now, from the Toolbox (if this is not visible go
to Tools » Toolbox) and click on the Image tool. With the image tool selected
click in the form detail section.

The Insert Picture dialog box appears. Select the image that you want to include
in the form and click OK. Access inserts your image in the image control on the
form. Select the image and position in the correct location.

As our chosen image is a particular colour, we also need to modify the


background colour of the form details section to match. If we right-click on an
empty section of the form background, and from the pop-up menu chose Fill/Back
Color and select a matching colour (in our case black).
5. Next we want to add a Check Box control. Add the checkbox to the bottom left
hand side of your form.

For the properties of the check box, set the name of the control to chkShowHide,
then from the data tab set a default value of 0 for the control.

Set the label caption for the check box to "Don't show this screen again"
6. Add a label control to the bottom right hand corner of the form. Set the name for
the control to lblClose and set the caption for the label to "Close". We will use
this to close the splash screen form by adding code to the click event of the label.
7. If we view the form in form view it will now look similar to the following
example:
8. Now, we need to add code to the On Click event of the Close label that will act as
a command to close the splash screen form. In design view of the form, select the
label (lblClose) and from the properties sheet choose the Event tab, then select the
On Click event.

Using the drop down arrow in the On Click property, select [Event Procedure]
and then click on the Ellipsis button (...) to open up the Visual Basic Editor. Enter
the following code:
9. Private Sub lblClose_Click()
10. On Error GoTo Err_lblClose_Click
11.
12.
13. ' Close the splash screen &
14. ' Open the main database form, frmMain
15.
16. DoCmd.Close
17. DoCmd.OpenForm "frmMain"
18.
19. Exit_lblClose_Click:
20. Exit Sub
21.
22. Err_lblClose_Click:
23. MsgBox Err.Description
24. Resume Exit_lblClose_Click
25.
End Sub

26. We also need to add some code to the Form Open and Form Close events, that
will perform actions depending on the selection made in the checkbox contained
on the form (the checkbox that gives the user the option of not displaying the
splash screen in future when they open the database). The events will set options
as to which form is displayed at start-up, dependant on user preference.

Add the following two sets of code to the Open and Close event procedures for
the form:
27. Private Sub Form_Open(Cancel As Integer)
28.
29. On Error GoTo FormOpen_Err
30. If (CurrentDb().Properties("StartupForm") =
"frmSplashScreen" Or _
31. CurrentDb().Properties("StartupForm") =
"Form.frmSplashScreen") _
32. Then
33. Forms!frmSplashScreen!chkHideSplash = False
34. Else
35. Forms!frmSplashScreen!chkShowHide = True
36. End If
37. FormOpen_Exit:
38. Exit Sub
39.
40. FormOpen_Err:
41. If Err = 3270 Then
42. Forms!frmSplashScreen!chkShowHide = True
43. Resume FormOpen_Exit
44. End If
45.
46. End Sub
47.
48. '---------------------------------------------------------------
-
49.
50. Private Sub Form_Close()
51.
52. On Error GoTo Form_Close_Err
53. If Forms!frmSplashScreen!chkShowHide Then
54. CurrentDb().Properties("StartupForm") = "frmMain"
55. Else
56. CurrentDb().Properties("StartupForm") =
"frmSplashScreen"
57. End If
58. Exit Sub
59.
60. Form_Close_Err:
61. If Err = 3270 Then
62. Dim db As DAO.Database
63. Dim prop As DAO.Property
64. Set db = CurrentDb()
65. Set prop = db.CreateProperty("StartupForm", dbText, _
66. "frmSplashScreen")
67. db.Properties.Append prop
68. Resume Next
69. End If
70.
End Sub

71. Save the design of the splash screen, then go to the Tools menu, where we need to
set the start-up options.

From the menu, choose Startup to display the startup options dialog box.

Select frmSplashScreen in the Display Form/Page drop down list.

This form will now be displayed the first time that the database is opened.

Вам также может понравиться