How to Play Video on Access Form




How to Play Video on MS Access Form

Other than displaying the PDF or picture on MS Access form, we can also able to play the video as well. In this How To, I will show how to display video by selecting the video name from the list and the video will start playing on the video frame as shown below. I will record the path or location of video file in the table. The list box on form will provide a video list from the table. The video will play after selecting the video name from the list.

play-video

Step by Step of How to create a form that can play video on

Step 1 Create Video Table

Create a table with field name VDO_ID, VDOName, and VDOLink as shown in the picture below. Save table as “VideoList”

create-table

In the datasheet view of table, enter the video name on the VDOName field and the location of your video on the VDOLink field corresponding to the video name.

table-data

Step 2 Create Form and Insert List Box

  • Create a blank form
  • Under Design menu, click on the List Box
  • Place a list box on the form

select-list-box

  • Follow the List Box Wizard
  • Select option “I want the list box to get the values from another table or query
  • Then click Next>

select-list-box-design

  • Select VideoList table then click Next>

select-table

  • Select all fields to the right then click Next>

import-fields

  • Select field VDOName to sort the list by vide name
  • Click Next>

sort-field

  • Leave the Hide key column as checked then click Next>

hide-pri-key

  • Rename the list box. I name it as List0 then click Finish

name-list-box

Form View

We will see there are two columns displayed on the list box. The VDO_ID which is the primary key is hidden. There are three columns, but the 1st column has the width = 0” which is unable to see. In this How To, I don’t want to show the address or location of video file. So we I just want to display only the video name in the list box. So I need to change some formats of the list box.

list-done

Open form in design mode, then double click on video list box to bring up the property sheet. Click on Format tab and update the Column Widths to 0;2;0 (VDO_ID, VDOName, VDOLink) as shown in the picture below.

format-listbox

Open View Form, now the video list box will display one column (the 2nd column is video name). However, the 1st column and the 3rd are hidden.

update-list-box



Step 3 Insert Video Player frame

  • Under Design menu, click on the ActiveX Controls
  • Select Windows Media Player at the bottom on ActiveX Control window
  • Click OK

active-x

select-wmplayer

  • Move the video frame to the position you like
  • You can rename the video ActiveX Controls name or leave it as it is (WindowsMediaPlayer2).

insert-wmplayer

Step 4 Coding

  • Double click on the video list box to open the property sheet of the list box
  • Select [Event Procedure] under the After Update event
  • Click 3 dot (…) to open the VBA of After Update event

list-event

  • Enter VB code below “Me.WindowsMediaPlayer2.URL = Me.List0.Column(2)”
  • The column 2 of list box is video name field (VDOName)

Private Sub List0_AfterUpdate()

         Me.WindowsMediaPlayer2.URL = Me.List0.Column(2)

End Sub

Finish

Open form view and click on the video name on the video list. The video will play on the video ActiveX Controls box on the left hand side of form as shown below. The video will change when we click other videos on the list.

play-video

change-video



Related posts