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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using variables in path and command line with the Shell Function

Status
Not open for further replies.
May 30, 2004
15
0
0
US
Can anybody suggest a way for me to click a command button that will pass a string (that uses varibales) to the command line?

On my current Access form I have a command button with the HyperLink property set to "Bptviewer.jar"

When I click this command button Access has no problem running the .jar file as long as it resides in the application path. When this .jar file is run this way, without any command paremeters, it immediately opens an "open file" dialog box forcing the user to select a file to open.

Note: The .jar file is able to accept command paremeters so that at command prompt you can simply type "Bptviewer.jar filename.jpg" and the viewer will open the file immediately without prompting the user to select the file.

Failed Attempt 1:
I have the OnFormLoadproperty set the HyperLink value of a command button to mdbPath & "panos/Bptviewer.jar" and that successfully opens the .jar file. I got excited when that worked so I tried to include the file name variable by changing the HyperLink property to mdbPath & "panos/Bptviewer.jar" & " " & [comboFileName].[ItemData](0) & ".jpg"

The Hyperlink property did not let me include paremeters following the "Bptviewer.jar" and gives me the following error:

error.gif



Failed Attempt 2:
My next strategy was to use the Shell command in VB. I wrote the following code behind a command button..

Y = mdbPath & "panos/Bptviewer.jar" & " " & [Combo40].[ItemData](0) & ".jpg"

Shell "Y", vbNormalFocus


That also did not work. I've attempted all kinds of syntax with the Shell command and still nothing works. I've searched all over tek-tips, google, and the VB and Access help menus and can still not figure this out. It seems like it shouldn't really be that difficult.

Can anybody suggest a way for me to simply click a command button that will pass a string (that uses varibales) to the command line?
 
You may try something like this:
CreateObject("WScript.Shell").Run Chr(34) & mdbPath & "panos/Bptviewer.jar" & Chr(34) & " " & Chr(34) & [Combo40].ItemData(0) & ".jpg" & Chr(34)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top