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

Combo Box to set parameter for shell command 1

Status
Not open for further replies.

jpkeller55

Technical User
Apr 11, 2003
131
US
I have a form that has a command button that when clicked will open a specific Word document. The code below is the event procedure On Click. I have about 10 different documents based on the last name of an account and instead of writing this code 10 times for different documents and have ten command buttons, I would like to use a Combo Box to select a last name and have that value drive the query.
Code:
Private Sub Command2_Click()
Set Sh = CreateObject("WScript.Shell")
Sh.Run Chr(34) & "W:\JK\Orders\Anderson.doc" & Chr(34)
End Sub

For example:
If the last names are:
Anderson
Baker
Johnson
The corresponding Word documents are: Anderson.doc; Baker.doc; Johnson.doc and so on.

I have a query called LastNames that powers the combo box.

Thanks for your help. jpkeller
 
There is no need to shell, you can use FollowHyperlink. For example:

[tt]FollowHyperlink Me.cboCombo
FollowHyperlink Me.cboCombo.Column(1)[/tt]

Where the relevant column contains "W:\JK\Orders\name.doc
 
In the comboBox AfterUpdate event procedure:
CreateObject("WScript.Shell").Run """W:\JK\Orders\" & Me![combo name] & ".doc"""

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