Unanswered: Problems playing an audio file whose name is in a control of a form
Please, i'm having problems playing an audio file whose name is in a control of a form.
I created a button in a subform. The action that i expect to happen when i click this button is the following: i expect Windows Media Player to open the mp3 file whose name is in a control of the same subform. I don't know SQL, but i found a code somewhere sometime ago and it was working at that time. Now i created a new Database (wanting to re-use the code) and i think i did the correct adjustments to the code.
The problem is that it opens Windows Media Player, but the player says that the file selected to be played has the extension (.) wich is unknown to the player. It asks me if i want it to play the file anyway. I click "yes", but it fails.
Please help me to understand what is going wrong. This is the code:
Private Sub Command13_Click()
On Error GoTo Err_Command13_Click
Don't use a shell process to start the desired application, use the ShellExecute function instead:
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpszOp As String, _
ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal LpszDir As String, ByVal FsShowCmd As Long) As Long
Sub OpenFile(ByVal FilePath As String)
Const SW_SHOWNORMAL As Long = 1
ShellExecute 0, "open", FilePath, vbNullString, vbNullString, SW_SHOWNORMAL
OpenFile "U:\Music\Clannad\The Ultimate Collection\Nil Sen La.mp3"
I was not able to find how to use your code. If it's possible, please let me know exactly where i should put each of the 3 pieces of code you sent me. I understand i have a subroutine Command13_Click() to create. I understand you sent me 3 things:
1) the "declaration" of a function called "ShellExecute"
2) A Sub called "OpenFile" that uses this function
3) A line of code that uses the sub "OpenFile"
What i have to start to create the procedure that will be called when i click the button is:
I will let the thread as "not answared" for the next days, because i still have a "no sense" problem: It works perfectly in a "Test Database", but when i copy it to another "Test - Database", it doesn't work anymore. So i still may need some help in a few days when i will be finishing the creation of the Database.