Trước tiên bạn thêm vào form Active Control "Windows media Player" đặt tên là mediaplayer1. Nếu bạn k muốn thấy Active Control này khi View form thì bạn dùng thuộc tính Visible ẩn nó đi là được
ComboBox của bạn có :
+ Row Source l: SELECT [DANH SACH HOC SINH].[MaHS], [DANH SACH HOC SINH].[TenHS] FROM [DANH SACH HOC SINH];
+Column Count:2
+Column Witdth: 0";1; 'Combobox chỉ hiển thị tên học sinh thôi
Dùng đoạn code cho Combobox
Code:
Private Sub cboName_BeforeUpdate(Cancel As Integer)
Dim filePath As String
Dim Sql As String
Dim rs As DAO.Recordset
Sql = "Select [Am Thanh] from [DANH SACH HOC SINH] where [Mahs] =" & cboName.Column(0)
Set rs = CurrentDb.OpenRecordset(Sql)
If IsNull(rs.Fields("Am Thanh").Value) Then
'---- Neu file am thanh khong co
MsgBox "K ton tai file am thanh"
Else
filePath = rs.Fields("Am Thanh").Value
Me.MediaPlayer1.URL = filePath
End If
Set rs = Nothing
End Sub
Nếu bạn khó hiểu thì đưa email mình sẽ gửi chương trình demo. Diễn đàn k upload file được
Bookmarks