Introduction.
I have several label animation styles lined up to share with you, and we have already explored two of them in the last two articles:
In this lesson, we will explore two variations of the animation method we practiced last week. If you have already followed the steps for creating the sample labels and writing the program, you can reuse the same setup with only a few small adjustments.
The only change needed is in the position of the second label (lbl2
). The arrangement of labels from the previous animation method is shown below:
In this method, both labels are initially placed apart and then move toward each other until they meet at the final position, forming the 3D heading style.
If you prefer a variation with a stronger visual appeal, you can reduce the distance between the two labels and place them slightly closer together. This adjustment gives the animation a smoother and more polished effect.
The modified version of the design is shown below:
You can implement this variant of the earlier animation style by changing the Properties of the lbl2 label as given below.
The Design Change.
Make a copy of the Employees Form with the earlier animation method and change the Form name to something like Employee2_1 or any other name you prefer.
Open the Employee2_1 in Design View.
Click on lbl2 (the label with the White-colored label and display its Property Sheet (View -> Properties).
Change the Property Values as shown below. The only change that you need to make is the left Property value only. But, the full Property Values are reproduced here with the change in the Left Property:
- Width = 2.9924
- Height = 0.3549
- Top = 0.125
- Left = 3.6354
- Back Style = Transparent
- Border Style = Transparent
- Font Name = Verdana
- Font Size = 18
- Text Align = Center
- Font Weight = Bold
- ForeColor = #FFFFFF
Once you make the Left Property Value change, the label will move into place as shown in the second image above.
Display the Code Module of the Form (View -> Code) while the Employee2_1 Form is still in the design view.
Copy and paste the following modified Code into the Form Module, overwriting the existing VBA Code.
The Form Module VBA Code.
Option Compare Database Option Explicit 'Global declarations 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 = 3.6354 * twips Me.lbl2.Top = 0.125 * twips Me.lbl2.Width = 2.9924 * twips Me.lbl2.Height = 0.3549 * twips txtName = UCase(Me![first name] & " " & Me![Last name]) Me.lbl1.Caption = txtName Me.lbl2.Caption = txtName i = 0 Me.TimerInterval = 25 End Sub Private Sub Form_Timer() Dim m, L1, L2 i = i + 1 m = i Mod 2 Select Case m Case 1 L1 = Me.lbl1.Left L1 = L1 + (0.084 * twips) Me.lbl1.Left = L1 Case 0 L2 = Me.lbl2.Left L2 = L2 - (0.084 * twips) Me.lbl2.Left = L2 End Select DoEvents If i > 12 Then Me.TimerInterval = 0 i = 0 End If End Sub
Save the Form and open it in Normal View.
Move the Employee Records forward using the record navigation buttons and watch the refined animation of employee names.
I hope you like the overall impact of the change in the earlier animation method.
The Design Changes.
We will look into another variant of the same animation method with the following design change:
In this method, the label
lbl2
is placed belowlbl1
. Both labels are then gradually moved toward each other until they overlap in a way that they create a 3D-style header.Make a Copy of the Employee2_1 Form and save it with the name Employee2_2.
Open the Form in Design View.
Click on the label with the White-colored text (with the Name Property Value lbl2) to select it.
Display the Property Sheet (View -> Properties) and change the following Property Values as shown below:
- Width = 2.9924
- Height = 0.3549
- Top = 0.5313
- Left = 2.5729
- Back Style = Transparent
- Border Style = Transparent
- Font Name = Verdana
- Font Size = 18
- Text Align = Center
- Font Weight = Bold
- ForeColor = #FFFFFF
Display the Code Module of the Form (View ->Code).
Copy and paste the following Code into the Form VBA Module, overwriting the existing Code.
The Form Module 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.5521 * twips Me.lbl1.Top = 0.1569 * twips Me.lbl1.Width = 2.9924 * twips Me.lbl1.Height = 0.3549 * twips Me.lbl2.Left = 2.5729 * twips Me.lbl2.Top = 0.5313 * 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 = 50 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.Top L1 = L1 + (0.084 * twips) Me.lbl1.Top = L1 Case 1 L2 = Me.lbl2.Top L2 = L2 - (0.084 * twips) Me.lbl2.Top = L2 End Select DoEvents If i > 4 Then Me.TimerInterval = 0 i = 0 End If End Sub
Save the Form and open it in Normal View.
Move the employee records forward using the Record Navigation buttons and observe how the new animation method is applied in the same 3D style.
Next week we will learn a different and interesting style of the label animation method.
[...] This post was mentioned on Twitter by aprpillai. aprpillai said: Label Animation Variant: I have several Label Animations Styles in store for you and we have http://goo.gl/fb/MH31a [...]
ReplyDelete