Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Label Animation Style-2

Last week we have learned a simple label animation method to display Employee Names, and made it to appear character by character from right side of the label to full view. The animated label gives the Form a lively look and makes it more interesting to the  User to work with the Screen.

This week we will learn a different label animation method with the same set of labels. In the earlier method we have used two identical labels to give the employee name a 3D effect.  We will stick with the same design but the labels will be put horizontally apart in the design as shown below:

In the Current-Event Procedure of the Form the Labels will be moved in opposite direction and finally assembled into a 3D heading style as shown below:

This happens every time an employee record become current.  The labels will restart from their original design position and slowly move in opposite direction and stay in place to form the 3D Style Employee Name.

If you have gone through the earlier label animation design task then it is easy to implement this one very easily.  All you have to do is to set the following Property Settings of lbl1 and lbl2 and copy the VBA routines into the Employee Form Module.

  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 name it as Employee2.
  3. Open the Employee2 Form in Design View.
  4. Click on the top label at the header of the Form and drag and move it to the right so that we will be able to click and select the labels individually and set their properties.
  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
    • Fore Color = 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
    • Fore Color = 16777215
  9. Display the Code Module of the Form (View- -> Code).
  10. Copy and Paste the following VBA Code overwriting the existing 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
    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

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

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


Label Animation Style-1

A Form with lively Objects like Animated Command Buttons or Animated Giffs or Moving Text etc. makes it more interesting to the User to work with our MS-Access Applications.  MS-Access doesn't have any of those things built-in or ready made to use it quickly. Our imagination and ingenuity is the only tool available to create something with the existing, strictly for business like, features provided in MS-Access.

After working with MS-Access for sometime I got bored with whatever we have in MS-Access. I wanted to make something more eye-catching to kill the boredom. As the saying goes "Necessity is the father of inventions", I have invented and developed some of the interesting features like: Command Button Animation, Animated Floating Calendar, Usage of Office Assistant in MsgBoxes, Animating Label on search success and others.

Today we will learn a simple Label Animation Technique with an example on the Employees Form from Northwind.mdb sample database.

  1. Import the following objects from C:\Program Files\Microsoft Office\Office11\samples\Northwind.mdb sample database.:
    • Table: Employees
    • Form: Employees

    If you open the Employees Form in Normal View you can see that the Employee's; Name; Firstname and Lastname joined together; is displayed on the Header of the Form in a Text Box. When you make some other record current on the Form the employee's full name changes on the Form Header Textbox as well.

    We will add some animated effect to this and make the employee name appear slowly from right edge of the label to the left, character by character, and move 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
    • Fore Color = 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 high-light the existing VBA Routines and press Del Key to delete them.
  8. Copy the following VBA Code and paste it into the Code Module of the Form.
    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
      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 normal view.
  11. When you open the Form you will find the Employee Name is moving into place slowly from right to left, character by character, in the header-label.

  12. Click on the Navigation button to move the records forward one by one.
  13. The names of the employees will be displayed in the same style by moving from right edge of the label to the left.

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

  1. Open the Employee Form in Design View.
  2. Select the header label.
  3. Click on the Copy, Paste Tool Bar buttons to make a copy of the label (or select Copy, Paste Options from View).
  4. Click on the new Label to select it, if it is not in selected state.
  5. Display the Property Sheet of the Label (View - ->Properties).
  6. Change the following Property Values as shown below:
    • Name = lbl2
    • Fore Color = 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.  Sample design image is given below:
  8. I have already included the line of code necessary to run this trick.  All you have to do is to 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 n normal View.

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



Subscribe in a reader
Your email address:

Delivered by FeedBurner


Popular Posts

Search This Blog

Blog Archive

Powered by Blogger.

Follow by Email


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

Featured Post

WithEvents and Report Line Highlighting

Introduction This is really a re-run of an earlier Post: Highlighting Reports published during August, 2007.  The full Code was written on ...


Blog Archive

Recent Posts