ACC97: Example Using Animation ActiveX Control in MS Access 97

ID: Q163440


The information in this article applies to:
  • Microsoft Access 97


SUMMARY

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

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:

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

Example 1: Using the Animation Control to Animate a Command Button

  1. Copy Firework.avi from the \Clipart\Mmedia folder on your Microsoft Office 97 Professional Edition compact disc to your computer hard drive.


  2. Start Microsoft Access and create a new blank database called Animate.mdb.


  3. Create a new form not based on any table or query in Design view.


  4. Add a command button to the form, and set the following properties:


  5. 
          Command button
          --------------
          Name: cmd1
          Caption: Play Animation
          Left: 1"
          Top: .5"
          Width: 1"
          Height: 1"
          OnClick: [Event Procedure] 
  6. Type the following code in the command button's OnClick event procedure:


  7. 
          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 
  8. On the Insert menu, click ActiveX Control.


  9. In the Insert ActiveX Control dialog box, select Microsoft Animation Control, version 5.0, and then click OK.


  10. Set the following properties for the animation control:


  11. 
          Animation control
          -----------------
          Name: an1
          Visible: No
          Left: 1"
          Top: .5"
          Width: 1"
          Height: 1" 
  12. Save the form as frmAnimate, and then switch to Form view.


  13. Click the Command button and note that the Firework.avi file plays.


Example 2: Selecting and Playing an Animation File

  1. Follow steps 1 through 3 in Example 1.


  2. Add a command button to the form, and set the following properties:


  3. 
          Command button
          --------------
          Name: cmd2
          Caption: Select && Play
          OnClick: [Event Procedure] 
  4. Type the following code in the command button's OnClick event procedure:


  5. 
          Private Sub cmd2_Click()
             With cd2
                .Filter = "avi (*.avi)|*.avi"
                .ShowOpen
             End With
             With an2
                .AutoPlay = True
                .Open cd2.FileName
             End With
          End Sub 
  6. On the Insert menu, click ActiveX Control.


  7. In the Insert ActiveX Control dialog box, select Microsoft Animation Control, version 5.0, and then click OK.


  8. Set the Name property of the animation control to an2.


  9. On the Insert menu, click ActiveX Control.


  10. In the Insert ActiveX Control dialog box, select Microsoft Common Dialog Control, version 5.0, and then click OK.


  11. Set the Name property of the common dialog control to cd2.


  12. Save the form as frmSelectPlay, and then switch to Form view.


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



REFERENCES

For more information about the Animation ActiveX Control, search the Help Index for Animation control.

For more information about Common Dialog ActiveX Control, search the Help Index for CommonDialog control.

Additional query words: OLE custom

Keywords : kbprg kbusage
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: November 10, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.