Microsoft KB Archive/163440

= ACC97: Example Using Animation ActiveX Control in MS Access 97 =

Article ID: 163440

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q163440



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



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

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access 97" manual.



MORE INFORMATION
The Animation ActiveX Control enables you to play .avi files on a Microsoft Access 97 form. When you open the form in Design view, you can see the control; in Form view, however, 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 (RLE). In addition, the .avi file cannot contain any audio components.

If you use an unsupported file format with the animation control, you receive the error message "Unable to Open AVI File." For more information about this error message, please see the following article in the Microsoft Knowledge Base:

162978 ACC97: "Unable to Open AVI File" Error Using Animation Control

Example 1: Using the Animation Control to Animate a Command Button
 Copy Firework.avi from the \Clipart\Mmedia folder on your Microsoft Office 97 Professional Edition compact disc to your computer hard drive. 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.  Add a command button to the form, and set the following properties:      Command button --     Name: cmd1 Caption: Play Animation Left: 1"     Top: .5" Width: 1"     Height: 1" OnClick: [Event Procedure]   Type the following code in the command button's OnClick event procedure: Private Sub cmd1_Click With An1 .Visible = True .AutoPlay = True ' Type the full path to Firework.avi on the following line. .Open "Firework.avi" End With End Sub  On the Insert menu, click ActiveX Control.</li> In the Insert ActiveX Control dialog box, select Microsoft Animation Control, version 5.0, and then click OK.</li>  Set the following properties for the animation control: <pre class="fixed_text">     Animation control -     Name: an1 Visible: No     Left: 1"      Top: .5" Width: 1"     Height: 1" </li> Save the form as frmAnimate, and then switch to Form view.</li> Click the Command button and note that the Firework.avi file plays.</li></ol>

Example 2: Selecting and Playing an Animation File
<ol> Follow steps 1 through 3 in Example 1.</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> On the Insert menu, click ActiveX Control.</li> In the Insert ActiveX Control dialog box, select Microsoft Animation Control, version 5.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, version 5.0, and then click OK.</li> Set the Name property of the common dialog control to cd2.</li> Save the form as frmSelectPlay, and then switch to Form view.</li> Click the command button. Note that an Open dialog box appears and enables you to select the Firework.avi file, and then the .avi plays on the form.</li></ol>

<div class="references_section">