COMMAND-BUTTON ANIMATION
Microsoft Access (the Relational Database Management System), is the Jewell among Ms-Office Suite of Applications, comes with superior Designing Tools and with built-in Visual Basic Language. These Pages are not intended for Beginner’s Tutorial Lessons but for those who have at least some basic knowledge of Designing MS-Access Tables, Queries, Forms, Reports, Macros and have general understanding of Visual Basic (the Programming Language of all MS-Office Applications) Modules, Function Procedures, Event Procedures etc.
When we develop an Application under any Database Management System it should be User-friendly and visually pleasing too. An un-attractive design spoils the appeal of the whole Project and it reflects the developer’s lack of creativity and indirectly reflects his inability to approach data processing problems effectively as well.
You can cook good food in the Kitchen but if the final presentation on the Table is bad then all the efforts put behind the scene doesn’t get the attention that it deserves. Like the saying goes, “face is the mirror of mind”, attractively designed Screens and Reports definitely have an appeal to the Users.
First, ensure that the essential Reference Library Files are attached to your Project. Display the Visual Basic Editor Window. Select Visual Basic Editor Option from Tools Menu or Code from View Menu. On the Visual Basic Editor Window Select References… from Tools Menu. Put check mark on the following Library Files in the Available References Dialogue Control:
- Visual Basic for Applications
- Microsoft Access 11.0 Object Library
- OLE Automation
- Microsoft DAO 3.6 Object Library
- Microsoft ActiveX Data Objects 2.5 Library
- Microsoft Office 11.0 Object Library
- Microsoft Visual Basic for Applications Extensibility 5.3

The Version Numbers of Library Files will be different based on what MS-Office version you are using. The Library File's List will be in alphabetical order. After you put check marks all the selected items will appear in the list on the top.
Copy and paste the following Code into a New Global Module:
Public Function ButtonAnimate(ByVal strForm As String, _
ByVal mode As Integer, ByVal lblName As String)
'------------------------------------------------------------
'Command Button Animation
'Author : a.p.r. pillai
'Date : September 2006
'------------------------------------------------------------
Dim FRM As Form, l As Long, t As Long
On Error GoTo ButtonAnimate_Err
Set FRM = Forms(strForm)
l = FRM.Controls(lblName & "Box").Left
t = FRM.Controls(lblName & "Box").Top
If (mode = 1) And (FRM.Controls(lblName & _
"Box").Visible = False) Then
FRM.Controls(lblName & "Box").Visible = True
FRM.Controls(lblName).Left = l - (0.0208 * 1440)' 0.0208 inches
FRM.Controls(lblName).Top = t - (0.0208 * 1440)' 0.0208 inches
FRM.Controls(lblName).FontWeight = 700
ElseIf (mode = 0) And (FRM.Controls(lblName & "Box").Visible = True) Then
FRM.Controls(lblName & "Box").Visible = False
FRM.Controls(lblName).Left = l
FRM.Controls(lblName).Top = t
FRM.Controls(lblName).FontWeight = 400
End If
ButtonAnimate_Exit:
Exit Function
ButtonAnimate_Err:
'Err.Clear
Resume ButtonAnimate_Exit
End Function
NB:All object specifications in this site are in U.S. measurements.
Those who follow Metric System please convert the values or change the Regional Settings into U.S. on Control Panel.
Command Button Design:

1. Create a Command Button on the Footer Section of a Form
2. Display the Property Sheet of the Command Button and change the following Properties:
Name = cmdClose
Caption = Close
ControlTipText = Click
3. Create a Rectangle Control on the Footer of the Form slightly smaller by Height and Width of the Command Button so that when the Command Button is placed over the Rectangle Control it completely hides it. Change the following properties of the Rectangle Control:
Name = cmdCloseBox
Note : The Rectangle Control's Name must be exactly the same Name of the Command Button with the 'Box' suffix.
Visible = False
SpecialEffect = Shadowed
BorderColor = 0
BorderStyle = Solid
BackStyle = Transparent
4. Drag the Rectangle control correctly underneath the Command Button. You can use Ctrl-Key with Arrow Buttons in MS-Access 2000 or Arrow Keys in later Versions to move the Control precisely under the Command Button. The Rectangle control will not be visible when correctly placed underneath the Command Button. If necessary, click the Send-to-Back Toolbar Button (or Select Send-to-Back from the Format Menu) if the Rectangle Control is overlapping the Command Button.
5. Copy and paste the following Code into the Form’s Visual Basic Module and save the Form.
Private Sub cmdClose_MouseMove(Button as Integer, _
Shift as Integer, X as Single, Y as single)
ButtonAnimate Me.Name, 1, "cmdClose"
End Sub
Private Sub FormFooter_MouseMove(Button as Integer, _
Shift As Integer, X As Single, Y As Single)
ButtonAnimate Me.Name, 0, "cmdClose"
End Sub
6. Open the Form in Normal View and try moving the Mouse over the Command Button and over the blank area of the Form Footer in a continuous stroke. When the Mouse is over the Button the Button moves slightly up and to the left showing up the Rectangle Frame as if it is the shadow of the Command Button and when the Mouse is dragged over the blank area of the Form Footer the Button goes back to its original state hiding the shadow. When this action is repeated the Button becomes lively and responds to the User every time the mouse is passed over the Button. Labels: msaccess animation
Any Number of Command Buttons can be added this way at the Form Footer (or Form Header Section, Detail Section) by placing the code for MouseMove Events. When the ButtonAnimate() Function is called, the Function Parameter Value 1 moves the Button up and 0 brings it back to its original position. If more than One button is added at the Footer, each Button should have its own Call to the ButtonAnimate() Function with 1 & 0 Values at the Command Button & Form Footer MouseMove Event Procedures respectively. --oOo--
Download Demo Database
Next >> Create 3D Text Headings on Forms and Reports

















0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home