Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Label Animation in Colors


We have learned several label animation methods, through the last few posts dedicated to this topic, but we will try another trick, with the last design that you have created to try out the Zoom-in method.

In this method, we will play with colors and each letter of the name is applied with different colors generated randomly. Besides that, the name of the employee is plotted in a magical way by displaying odd-numbered letters first on odd-numbered labels i.e. lbl01, lbl03, lbl05, and even-numbered letters displayed on even-numbered labels i.e. lbl02, lbl04, lbl06, and so on. The letters will be plotted on the labels in a fixed time interval giving it an animated effect.

After this two-step action, the employee name display will be completed on the Header of the Form to view.

You can easily implement this method if you have tried out the earlier label animation method we have seen last week.

The Design Task.

  1. Make a Copy of the Employees Form, which we have designed last week, and name it Employees_2 or any other name you prefer.

    The sample design of the Form, with twenty labels placed close together in the Header of the Form, with the Name Property Values set as lbl01 to lbl20, is given below:

  2. Display the Code Module of the Form (View - -> Code), after opening the Form in Design View.

  3. Copy and Paste the following VBA Code into the Form Module overwriting the existing Code.

    The Form Module Code.

    Option Compare Database
    Option Explicit
    Dim j, txtName, ctrl As Label
    Private Sub Form_Current()
    Dim t, m, R, G, B
    Randomize (Timer)
    txtName = Me![first name] & " " & Me![Last name]
    For j = 1 To 20
       Set ctrl = Me("lbl" & Format(j, "00"))
       ctrl.Caption = ""
    For j = 1 To Len(txtName) Step 2
       Set ctrl = Me("lbl" & Format(j, "00"))
       R = Int(Rnd(1) * 64)
       G = Int(Rnd(1) * 128)
       B = Int(Rnd(1) * 255)
       ctrl.ForeColor = RGB(R, G, B)
       ctrl.Caption = Mid(txtName, j, 1)
    t = Timer
    Do While Timer < t + 0.1
    For j = 2 To Len(txtName) Step 2
       Set ctrl = Me("lbl" & Format(j, "00"))
       R = Int(Rnd(1) * 255)
       G = Int(Rnd(1) * 128)
       B = Int(Rnd(1) * 64)
       ctrl.ForeColor = RGB(R, G, B)
       ctrl.Caption = Mid(txtName, j, 1)
    t = Timer
    Do While Timer < t + 0.1
    End Sub
  4. Save the Form with the new VBA Code.

    The Demo Run.

  5. Open the Form in the normal view.

  6. Use the record navigation button to move the record forward or back and watch how the employee name is displayed in the header labels.

The sample screen in Normal View is given below:

Each character of the name will be displayed in different colors and in one-tenth of a millisecond time interval, giving it an animated effect. The color codes are generated randomly.

In this control program, we have used two delay loops, instead of using the Form's default Timer Interval Event Procedure.

You can modify the given value 0.1 in the program line Do While Timer < t + 0.1 to increase or decrease the animation speed.

For example, the value 0.5 will slow down the action and 0.05 will run faster.

  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

1 comment:

  1. [...] This post was mentioned on Twitter by aprpillai. aprpillai said: Label Animation in Colors: We have learned several label animation methods, through last few… http://goo.gl/fb/PPMy6 [...]


Comments subject to moderation before publishing.




Post Feed


Popular Posts

Blog Archive

Powered by Blogger.


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