Opening a file with a command button

S

sistinus

What I'm trying to do is this. I have table called Videos that lists video
files on my computer. Two of the fields are Filename and FilePath. I'm
trying to make a command button in a form to play the video that corresponds
to the record that's open. If anyone could help me with this it would be a
big help. Thanks.
 
D

Dymondjack

Try the Shell command

Shell(FilePath & Filename)

If the video file has an associated program in the win registry it should
automatically execute that program (usually medai player).

Make sure the argument is a full path including extension.

"C:\Vids\MyVid.wmv"

Hopefully that helps

Jack
 
S

sistinus

That still doesn't tell me how to get the filename and filepath from the
record. Just typing the path\name in vba defeats the purpose. I have over
350 videos and I really don't want to type a different module for each video.
 
K

Keith Wilby

sistinus said:
That still doesn't tell me how to get the filename and filepath from the
record. Just typing the path\name in vba defeats the purpose. I have
over
350 videos and I really don't want to type a different module for each
video.

So just substitute control names to build the path string:

Dim strFilePath as String
strFilePath = Me.txtPath & "\" & Me.txtFilename
Shell(strFilePath)

Keith.
www.keithwilby.co.uk
 
D

Daniel Pineault

The easiest way to open any type of file is to use the FollowHyperlink method
as it will open the file in the default application. So try something like:

Application.FollowHyperlink FilePath & FileName
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
P

papazar

sistinus said:
What I'm trying to do is this. I have table called Videos that lists
video
files on my computer. Two of the fields are Filename and FilePath. I'm
trying to make a command button in a form to play the video that
corresponds
to the record that's open. If anyone could help me with this it would be
a
big help. Thanks.
 
S

sistinus

Thanks. This worked like a charm.

Daniel said:
The easiest way to open any type of file is to use the FollowHyperlink method
as it will open the file in the default application. So try something like:

Application.FollowHyperlink FilePath & FileName
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top