Microsoft KB Archive/209919

= ACC2000: How to Use Animation ActiveX Control in Access =

Article ID: 209919

Article Last Modified on 6/24/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q209919



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SUMMARY
This article shows two examples of how to use the Animation ActiveX Control in a Microsoft Access database. The Animation ActiveX Control ships with Microsoft Office Developer Edition Tools.



MORE INFORMATION
With Animation ActiveX Control, you can play .avi files on a Microsoft Access form. When you open the form in Design view, you can see the control; however, in Form view, the control is hidden until you play the .avi file associated with the control. One common use for the animation control is to provide animation with command buttons. If you place the animation control on top of a command button and use the Click event of the button to invoke the Open and Play methods of the animation control, the button appears to be animated.

The Animation ActiveX Control supports only two types of .avi files: uncompressed .avi files, and .avi files that have been compressed using Run-Length Encoding. Sound components of .avi files are not played.

If you use an unsupported file format with the animation control, you receive the following error message:

Unable to Open AVI File

Example 1: Using the Animation Control to Animate a Command Button
 Start Microsoft Access and create a new blank database called Animate.mdb. Create a new form not based on any table or query in Design view. On the Insert menu, click ActiveX Control. In the Insert ActiveX Control dialog box, select Microsoft Animation Control, version 6.0, and then click OK.  Set the following properties for the animation control:   Animation control -  Name: an1 Visible: No  Left: 1"   Top: .5" Width: 1"  Height: 1"   Add a command button to the form, and set the following properties: <pre class="fixed_text">  Command button --  Name: cmd1 Caption: Play Animation Left: 1"  Top: .5" Width: 1"  Height: 1" OnClick: [Event Procedure] </li>  Type the following code in the command button's OnClick event procedure: Private Sub cmd1_Click Dim AviFile As String

' Type the full path to the .avi file on the following line. AviFile = "path and filename"

With an1 .Visible = True .AutoPlay = True .Open AviFile End With End Sub NOTE: For the code to run properly you must insert the correct path and filename of your .avi file. </li> Save the form as frmAnimate, and then switch to Form view.</li> Click the command button and note that the .avi file plays on top of the command button.</li></ol>

Example 2: Selecting and Playing an Animation File
<ol> Follow steps 1 through 3 in Example 1.</li> On the Insert menu, click ActiveX Control.</li> In the Insert ActiveX Control dialog box, select Microsoft Animation Control, version 6.0, and then click OK.</li> Set the Name property of the animation control to An2.</li> On the Insert menu, click ActiveX Control.</li> In the Insert ActiveX Control dialog box, select Microsoft Common Dialog Control 6.0, and then click OK.</li> Set the Name property of the common dialog control to Cd2.</li>  Add a command button to the form, and set the following properties: <pre class="fixed_text">  Command button --  Name: cmd2 Caption: Select & Play OnClick: [Event Procedure] </li>  Type the following code in the command button's OnClick event procedure: Private Sub cmd2_Click With Cd2 .Filter = "avi (*.avi)|*.avi" .ShowOpen End With With An2 .AutoPlay = True .Open Cd2.FileName End With End Sub </li> Save the form as frmSelectPlay, and then switch to Form view.</li> Click the command button.</li></ol>

Note that an Open dialog box appears and lets you select an .avi file, and then the .avi file plays on the form.

<div class="references_section">