<body><iframe src="http://www.blogger.com/navbar.g?targetBlogID=34083602&amp;blogName=LEARN+MS-ACCESS+TIPS+AND+TRICKS&amp;publishMode=PUBLISH_MODE_FTP&amp;navbarType=BLUE&amp;layoutType=CLASSIC&amp;homepageUrl=http%3A%2F%2Fmsaccesstips.com%2F&amp;searchRoot=http%3A%2F%2Fblogsearch.google.com%2F" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="30px" width="100%" id="navbar-iframe"></iframe> <div id="space-for-ie"></div>
Google Search and Banner
 

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

 
Your Ad Here
Saturday, September 09, 2006

COMMAND-BUTTON ANIMATION

Under Title Banner Button image

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.

Here, I would like to present some of the Controls and Programs that I have developed to use in my Projects and I am sure that you will find them interesting too. Example Codes are written for MS-Access 2000 and will run under later versions too.

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:


  1. Visual Basic for Applications
  2. Microsoft Access 11.0 Object Library
  3. OLE Automation
  4. Microsoft DAO 3.6 Object Library
  5. Microsoft ActiveX Data Objects 2.5 Library
  6. Microsoft Office 11.0 Object Library
  7. Microsoft Visual Basic for Applications Extensibility 5.3


Reference Library Image

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.

When the Mouse is passed over the Command Button it will move up a little to the left showing up its shadow underneath and when Mouse is moved over the blank area of the Form the Command Button goes back into its original state. When this action is repeated the Button gives a lively appearance responding to the User's mouse movements over it.

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:
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.

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

Labels:

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home