Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to Run Query Results on External Application

Status
Not open for further replies.

Musicguy

Technical User
Dec 28, 2000
10
US
I have an Access 2000 db of my favorite songs from hundreds of albums. I have also begun recording those songs in mp3 format and storing them on my hard drive. One of my queries returns the full path name of each song file as the field [SongFile].

I can query the db to get a list of songs I would like to hear, but my attempts to write a macro to open Winamp (external application) and then play the query results have been futile.

My macro will open the query, go to the [SongFile] field of the first record, copy it, and open Winamp. I can't get beyond that. I need to paste the query result into Winamp and then run it, and then go back to Access, get the next record result and run it, etc.

Perhaps a macro is not the way to go, but I can't even get to first base with the modules. Can anyone show me the way?
 
Hey MusicGuy,

First thing I would try is to see if you can call Winamp from a DOS command line. I am not sure if it will allow you to pass it a parameter of the MP3 to play. Run a DOS shell and then type the following using your path structure:
Code:
&quot;C:\Program Files\Winamp\Winamp.exe&quot; &quot;C:\Music\My Favorite MP3.MP3&quot; <enter>
If that brings up Winamp and plays the song, then you should be able to write a module attached to a form that has a button and a combobox of songs that when pressed will play your favorite song:
Code:
stAppName = &quot;C:\Program Files\Winamp\Winamp.exe &quot; &amp; &quot;&quot;&quot;&quot; &amp; Me!cboExcel.Value &amp; &quot;&quot;&quot;&quot;
Call Shell(stAppName, 1)
Let me know if you need any more help...


Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
First of all when I call a program from Access or VB I see if you can pass a document or paramter to it.
Easy way to find out, is double click the MP3 file in Windows Explorer.
If it loads the file in the correct player and starts playing it then your work is half done.

In Windows Explorer click the &quot;View&quot; menu then &quot;Options&quot;

next click the &quot;Files Type&quot; TAB
now the fun part, find the .mp3 file extension and look for the program that plays it.

When you find it
Click Edit button and the open option in the list
you should see something like this:
&quot;C:\Program Files\Windows Media Player\mplayer2.exe&quot; /Play &quot;%L&quot;

I have NT4
Now if you use this paramters and all in your VBA code it will work the same.

here is a groovy little function I made for you.
---------------------

Public Function PlayMp3(SongToPlay)
Dim x As Variant
x = Shell(&quot;C:\Program Files\Windows Media Player\mplayer2.exe /Play &quot; &amp; SongToPlay, vbNormalFocus)
'notice I dropped the &quot;%L&quot; and put the &quot;songtoplay&quot; in its place
End Function

---------------------
Note change the mplayer2 to the valid location where your's is.

to test it:
Click the modules TAB and Create a ewn module and then paste the whole thing in the big white space.
Save the module when done and you can call this function anywhere in your database including a macro

Press ctrl-G and paste this into the bottom window.
x=Playmp3(&quot;x:\fun\Ouch1.mpg&quot;)
then press the enter key

Change the x:\fun\Ouch1.mpg to a valid mp3 file on your computer.
Also I don't have an mp3 file to test it but the mplayer2 does work with both.



DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
Guys -

Thanks for the quick responses. The Winamp files have been properly associated all along, i.e. when I double click on an mp3 file, Winamp opens and plays the file.

With Terry's suggestion I created the following module:
Function Terry()
stAppName = &quot;C:\Program Files\Winamp\Winamp.exe &quot; &amp; &quot;&quot;&quot; &amp; Me!cboExcel.Value&quot; &amp; &quot;&quot;&quot;&quot;
Call Shell(stAppName, 1)
End Function

When I run it in Design view, it opens Winamp. When I close Design view, however, the Run button is not active on the Module page as if something is wrong. Anyway, I created a form for my SongFind query with a combo box and a command button. I set the command button to run a macro, but I can't get a macro to run the module?? What am I doing wrong here? Also, will the Me!cboExcel.Value statement get the SongFile field data out of the query?

With Doug's suggestion I created the following module:
Public Function PlayMp3(SongFile)
Dim x As Variant
x = Shell(&quot;C:\Program Files\Winamp\Winamp.exe&quot; &amp; SongFile, vbNormalFocus)
End Function

When I attempt to run it in Design view, I get a prompt for a macro, but when I type in a macro name, it just adds that text to the module text above. Again, when I leave Design view, the Run button is not active on the main Module page, and I don't know how to call the module from a macro.

I pressed ctrl-G and entered this in the bottom box:
x=PlayMp3(&quot;C:\My Music\458-08 Fleetwood Mac - One Together.mp3&quot;)

After pressing Enter, I got a &quot;File not found&quot; error. On pressing the Debug key, it highlighted the x=Shell(C:\ . . . . . vbNormalFocus) line from the function above.

Are we getting close? I really appreciate the help with this, but I am weak even on the fundamentals. Your patience and dilligence are appreciated.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top