databasedev.co.uk - database solutions and downloads for microsoft access

Microsoft Access Splash Screen Tutorial

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:

    The initial design of the splash screen
  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:

    The design of our splash screen
  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:
    Private Sub lblClose_Click()
        On Error GoTo Err_lblClose_Click
    
    
    ' Close the splash screen &
    ' Open the main database form, frmMain
    
        DoCmd.Close
        DoCmd.OpenForm "frmMain"
    
    Exit_lblClose_Click:
        Exit Sub
    
    Err_lblClose_Click:
        MsgBox Err.Description
        Resume Exit_lblClose_Click
    
    End Sub
  9. 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:
    Private Sub Form_Open(Cancel As Integer)
    
        On Error GoTo FormOpen_Err
        If (CurrentDb().Properties("StartupForm") = "frmSplashScreen" Or _
          CurrentDb().Properties("StartupForm") = "Form.frmSplashScreen") _
            Then
            Forms!frmSplashScreen!chkHideSplash = False
        Else
            Forms!frmSplashScreen!chkShowHide = True
        End If
    FormOpen_Exit:
        Exit Sub
    
    FormOpen_Err:
        If Err = 3270 Then
            Forms!frmSplashScreen!chkShowHide = True
            Resume FormOpen_Exit
        End If
    
    End Sub
    
    '----------------------------------------------------------------
    
    Private Sub Form_Close()
    
    On Error GoTo Form_Close_Err
        If Forms!frmSplashScreen!chkShowHide Then
            CurrentDb().Properties("StartupForm") = "frmMain"
        Else
            CurrentDb().Properties("StartupForm") = "frmSplashScreen"
        End If
    Exit Sub
    
    Form_Close_Err:
        If Err = 3270 Then
            Dim db As DAO.Database
            Dim prop As DAO.Property
            Set db = CurrentDb()
            Set prop = db.CreateProperty("StartupForm", dbText, _
            "frmSplashScreen")
            db.Properties.Append prop
            Resume Next
        End If
        
    End Sub
  10. 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.

To see this example in action, you can download the sample Microsoft Access database from the Microsoft Access Forms page or the Microsoft Access Downloads page.