Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Label Animation Style-2

Introduction

Last week, we learned a simple label animation method that displayed employee names character by character from the right side of the label. This animation gave the form a lively appearance and made the screen more engaging for the user.

This week, we’ll try a different label animation method using the same set of labels. In the earlier Animation Style, we used two identical labels to create a 3D effect for the employee’s name. We’ll continue with the same design, but this time the labels will be placed horizontally apart in the layout, as shown below: 

In the Form_Current Event Procedure, the two labels will be programmed to move in opposite directions. As they gradually approach one another, they will finally align and merge together, forming a 3D-style heading as shown below:

This animation occurs every time an employee record becomes current. The labels restart from their original positions, move gradually in opposite directions, and finally settle to form the 3D-style employee name.

If you have already completed the earlier label animation task, implementing this method will be straightforward. Simply adjust the following property settings for lbl1 and lbl2, and then copy the VBA routines into the Employee form’s module.

The Label Animation Design.

  1. Open your database where you have tried the earlier example.

  2. Make a copy of the earlier Employee Form. We have tried the Label Animation and named it Employee2.

  3. Open the Employee2 Form in Design View.

  4. Click on the top label in the form’s header and drag it slightly to the right. This will allow you to select each label individually and adjust its properties as needed.

  5. Select the Label with the name lbl1.

  6. Display its Property Sheet (View - -> Properties) and set the following Property Values:

    • Name = lbl1
    • Width = 2.9924"
    • Height = 0.3549"
    • Top = 0.1569"
    • Left = 2.5194"
    • Back Style = Transparent
    • Border Style = Transparent
    • Font Name = Verdana
    • Font Size = 18
    • Text Align = Centre
    • Font Weight = Bold
    • ForeColor = 0
  7. Select the Label with the name lbl2.

  8. Display the Property Sheet and change the following Property Values:

    • Name = lbl2
    • Width = 2.9924"
    • Height = 0.3549"
    • Top = 0.125"
    • Left = 5.5313"
    • Back Style = Transparent
    • Border Style = Transparent
    • Font Name = Verdana
    • Font Size = 18
    • Text Align = Centre
    • Font Weight = Bold
    • ForeColor = 16777215
  9. Display the Code Module of the Form (View -> Code).

  10. Copy and paste the following VBA Code, overwriting the existing Code:

    The Form Module VBA Code.

    Option Compare Database
    Option Explicit
    
    Private Const twips As Long = 1440
    Dim i, j
    
    Private Sub Form_Current()
    Dim txtName As String
    Me.lbl1.Left = 2.5194 * twips: Me.lbl1.Top = 0.1569 * twips: Me.lbl1.Width = 2.9924 * twips: Me.lbl1.Height = 0.3549 * twips
    Me.lbl2.Left = 5.5313 * twips: Me.lbl2.Top = 0.125 * twips: Me.lbl2.Width = 2.9924 * twips: Me.lbl2.Height = 0.3549 * twips
    txtName = Me![first name] & " " & Me![Last name]
    Me.lbl1.Caption = txtName
    Me.lbl2.Caption = txtName
    i = 0
    Me.TimerInterval = 5
    
    End Sub
    
    Private Sub Form_Timer()
    Dim m, L1, L2
    i = i + 1
    m = i Mod 2
    Select Case m
        Case 0
            L1 = Me.lbl1.Left
            L1 = L1 + (0.084 * twips)
            Me.lbl1.Left = L1
        Case 1
            L2 = Me.lbl2.Left
            L2 = L2 - (0.084 * twips)
            Me.lbl2.Left = L2
    End Select
    DoEvents
    If i > 35 Then
       Me.TimerInterval = 0
       i = 0
    End If
            
    End Sub
  11. Save the Employee2 Form.

  12. Open the Employee2 Form in normal view

  13. Click on the Record Navigation control to advance each record forward one by one.

    For each record change, you will find the Employee Name Labels move towards each other and assemble into place to form a 3D heading.

  1. Textbox and Label Inner Margins
  2. Animating Label on Search Success
  3. Label Animation Style-1
  4. Label Animation Style-2
  5. Label Animation Variant
  6. Label Animation Zoom-in Style
  7. Label Animation in Colors
  8. Label Animation Zoom-out Fade
Share:

Label Animation Style-1

Introduction

A form with lively objects—such as animated command buttons, GIFs, or moving text—makes working with MS Access applications more interesting for the user. However, MS Access does not provide these features out of the box. To create dynamic elements, we must rely on our imagination and ingenuity, using the standard tools available in Access.

After working with MS Access for a while, I grew tired of repeatedly using the same static objects in application designs. I wanted to create something more eye-catching to make the experience more engaging. As the saying goes, “Necessity is the mother of invention.” This led me to develop several creative features, including: 

Today, we will learn a simple label animation technique using an example from the Employees form in the Northwind.mdb sample database.

  1. Import the following objects from the Northwind sample database.:

    • Table: Employees
    • Form: Employees

    If you open the Employees form in Normal View, you’ll see that the employee’s full name—firstname and lastname combined—is displayed in the form header within a text box. When you navigate to a different record, the full name in the header updates automatically.

    We will enhance this by adding an animated effect, making the employee name appear character by character, moving slowly from the right edge of the label to the left, and finally settling into place.

  2. Open the Employees Form in Design View.

  3. Delete the existing TextBox that displays the Employee's Name.

  4. Create a Label on the Header of the Form.

  5. Display the Property Sheet (View -> Properties) of the Label and change the following Property Values:

    • Name = lbl1
    • Width = 3.5"
    • Height =0.32"
    • Back Style = Transparent
    • Border Style = Transparent
    • ForeColor = 16777215
    • Font Name = Times New Roman
    • Font Size = 18
    • Font Weight = Bold
    • Text Align = Right
  6. Display the Code Module of the Form (View ->Code).

  7. Press Ctrl+A to highlight the existing VBA Routines and press the Del key to delete them.

  8. Copy the following VBA Code and paste it into the Code Module of the Form.

    Label Animation Code.

    Option Compare Database
    Option Explicit
    
    Dim txt1 As String, txtlen As Integer
    Dim j As Integer, txt2 As String
    
    Private Sub Form_Timer()
    j = j + 1
    If j <= txtlen Then
      txt2 = Left(txt1, j)
      Me.lbl1.Caption = txt2
      'Me.lbl2.Caption = txt2
      Else
      Me.TimerInterval = 0
    End If
    
    End Sub
    
    
    Private Sub Form_current()
           
    txt1 = UCase(Me![FirstName] & " " & Me![LastName])
    txtlen = Len(txt1)
    j = 0
    Me.TimerInterval = 50
    
    End Sub
  9. Save and Close the Employees Form.

  10. Open the Employees Form in the normal view.

  11. When you open the form, the employee name will gradually move into place from right to left, appearing character by character in the header label.

  12. Click the forward Navigation records button to move the records one by one.

  13. The names of the employees will be displayed in the same style by moving from the right edge of the label to the left.

Fancy Work to the Label.

We will add a little fancy work to the Employee Name for a three-dimensional backlit effect by copying the Label and placing it over the existing one. See the finished design of the image given below:

  1. Open the Employee Form in Design View.

  2. Select the header label.

  3. Click on the Copy, Paste ToolBar buttons to make a copy of the label (or select Copy, Paste Options from the View Menu).

  4. Click on the new Label to select it if it is not in the selected state.

  5. Display the Property Sheet of the Label (View ->Properties).

  6. Change the following Property Values as shown below:

    • Name = lbl2
    • ForeColor = 128
  7. Move the label up and over the first label and place it slightly down from the top edge of the first label and to the left, about the thickness of a hair.  The sample image design view is given below:

  8. I have already included the line of code necessary to run this trick.  All you have to do is enable that line in the VBA code, do the following:

  9. While the Form is still in design view, display the VBA Module (View ->Code)

  10. You will find the following line of code in the Sub Form_Timer() Event Procedure in a different color (most probably in green color):

  11. 'Me.lbl2.Caption = txt2

  12. Find the ' (single quote) character at the beginning of this line and delete it.

  13. Save and Close the Form.

  14. Open the Form in the Normal View.

    Now you will find the Employee Names appearing in animated characters, with the 3D effect, as shown in the second image above.

  1. Textbox and Label Inner Margins
  2. Animating Label on Search Success
  3. Label Animation Style-1
  4. Label Animation Style-2
  5. Label Animation Variant
  6. Label Animation Zoom-in Style
  7. Label Animation in Colors
  8. Label Animation Zoom-out Fade
Share:

PRESENTATION: ACCESS USER GROUPS (EUROPE)

Translate

PageRank

Post Feed


Search

Popular Posts

Blog Archive

Powered by Blogger.

Labels

Forms Functions How Tos MS-Access Security Reports msaccess forms Animations msaccess animation Utilities msaccess controls Access and Internet MS-Access Scurity MS-Access and Internet Class Module External Links Queries Array msaccess reports Accesstips WithEvents msaccess tips Downloads Objects Menus and Toolbars Collection Object MsaccessLinks Process Controls Art Work Property msaccess How Tos Combo Boxes Dictionary Object ListView Control Query VBA msaccessQuery Calculation Event Graph Charts ImageList Control List Boxes TreeView Control Command Buttons Controls Data Emails and Alerts Form Custom Functions Custom Wizards DOS Commands Data Type Key Object Reference ms-access functions msaccess functions msaccess graphs msaccess reporttricks Command Button Report msaccess menus msaccessprocess security advanced Access Security Add Auto-Number Field Type Form Instances ImageList Item Macros Menus Nodes RaiseEvent Recordset Top Values Variables Wrapper Classes msaccess email progressmeter Access2007 Copy Excel Export Expression Fields Join Methods Microsoft Numbering System Records Security Split SubForm Table Tables Time Difference Utility WScript Workgroup database function msaccess wizards tutorial Access Emails and Alerts Access Fields Access How Tos Access Mail Merge Access2003 Accounting Year Action Animation Attachment Binary Numbers Bookmarks Budgeting ChDir Color Palette Common Controls Conditional Formatting Data Filtering Database Records Defining Pages Desktop Shortcuts Diagram Disk Dynamic Lookup Error Handler External Filter Formatting Groups Hexadecimal Numbers Import Labels List Logo Macro Mail Merge Main Form Memo Message Box Monitoring Octal Numbers Operating System Paste Primary-Key Product Rank Reading Remove Rich Text Sequence SetFocus Summary Tab-Page Union Query User Users Water-Mark Word automatically commands hyperlinks iSeries Date iif ms-access msaccess msaccess alerts pdf files reference restore switch text toolbar updating upload vba code