ACC97: Example Using Animation ActiveX Control in MS Access 97
ID: Q163440
|
The information in this article applies to:
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
- 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.
- In the Insert ActiveX Control dialog box, select Microsoft Animation
Control, version 5.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"
- Save the form as frmAnimate, and then switch to Form view.
- Click the Command button and note that the Firework.avi file plays.
Example 2: Selecting and Playing an Animation File
- Follow steps 1 through 3 in Example 1.
- Add a command button to the form, and set the following properties:
Command button
--------------
Name: cmd2
Caption: Select && Play
OnClick: [Event Procedure]
- 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
- On the Insert menu, click ActiveX Control.
- In the Insert ActiveX Control dialog box, select Microsoft Animation
Control, version 5.0, and then click OK.
- Set the Name property of the animation control to an2.
- On the Insert menu, click ActiveX Control.
- In the Insert ActiveX Control dialog box, select Microsoft Common
Dialog Control, version 5.0, and then click OK.
- Set the Name property of the common dialog control to cd2.
- Save the form as frmSelectPlay, and then switch to Form view.
- 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