Ms-Access Advanced VBA Programming Techniques, Tips and Tricks.

Ads

Label Animation in Colors

We have learned several label animation methods, through 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 color generated randomly. Besides that, the name of the employee is plotted in a magical way by displaying odd numbered letters first in odd numbered labels i.e. lbl01, lbl03, lbl05 and even numbered letters displayed in 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 these two step action only 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.

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

    Sample design of the Form, with twenty labels placed close together on 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.

    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 = "" Next 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 DoEvents Loop Next 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 DoEvents Loop Next End Sub

  4. Save the Form with the new VBA Code.
  5. Open the Form in 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 milli-second's 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.


Share:

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 [...]

    ReplyDelete

Trending

Infolinks Text Ads

Popular Posts

Search This Blog

Blog Archive

Powered by Blogger.

Labels

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

Featured Post

Activity Dates and Quarterly Reports

There are four Quarters in a Year: Jan - Mar = 1st Quarter Apr - Jun = 2nd Jul - Sep = 3rd Oct - Dec = 4th First three months of the yea...

Labels

Blog Archive

Recent Posts