ACC97: Example Using Animation ActiveX Control in MS Access 97

Last reviewed: August 29, 1997
Article ID: Q163440
The information in this article applies to:
  • Microsoft Access 97

SUMMARY

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

This article shows two different examples of using 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:

   ARTICLE-ID: Q162978
   TITLE     : 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:

          Command button
          --------------
          Name: cmd1
          Caption: Play Animation
          Left: 1"
          Top: .5"
          Width: 1"
          Height: 1"
          OnClick: [Event Procedure]
    

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

  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 following properties for the animation control:

          Animation control
          -----------------
          Name: an1
          Visible: No
          Left: 1"
          Top: .5"
          Width: 1"
          Height: 1"
    

  9. Save the form as frmAnimate, and then switch to Form view.

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

Example 2: Selecting and Playing an Animation File

  1. Perform steps 1-3 in Example 1.

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

          Command button
          --------------
          Name: cmd2
          Caption: Select && Play
          OnClick: [Event Procedure]
    

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

  4. On the Insert menu, click ActiveX Control.

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

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

  7. On the Insert menu, click ActiveX Control.

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

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

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

  11. 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 : IntpCstm kbprg kbusage PgmHowTo
Version : 97
Platform : WINDOWS
Hardware : x86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.