Elyse,
I tried it here, using a pdf document on my desktop as the target address,
and it worked fine, opening the document with Adobe Reader 7 and leaving it
open. Assuming that the document that you are opening is a normal pdf, and
not some kind of template, I don't know why it's closing immediately.
Your syntax below seemed a little strange, though. In VBA I'd code it as:
Private Sub Combo1_AfterUpdate() 'Use AfterUpdate versus OnChange
Dim myStr as String
Select Case Me![Combo1]
Case "del user":
myStr = "D:\Adobe_Designer_Forms\deluser.pdf"
Case "chang user":
myStr = "D:\Adobe_Designer_Forms\disqual.pdf"
'Enter any other documents as case statements with proper path to
file.
End Select
'Remove the comment below to display the file path so that you can verify it.
' MsgBox myStr
Me.Command1.HyperlinkAddress = myStr
End Sub
It's not necessary to have any code attached to the button.
If you have the file names as a column in the RecordSourcefor the combo box
(what I'd do for easer maintenance), you can use the following instead of the
Select Case:
Private Sub Combo1_AfterUpdate()
Me.Command1.HyperlinkAddress = Combo1.Column (2)
'change the '2' to represent the column with the path to the file.
End Sub
HTH,
Bruce
elyse said:
Hi BruceS
When I click on the button(Command0), Adobe launches then quickly closes.
I've set the following properties. Maybe I've done something wrong.
Command0 (Button) - Hyperlink Address = (form1.Combo1)
Combo1(OnChange) =
Private Sub Combo1_Change()
If Me.Combo1.Value = "del user" Then
Me.Command0.HyperlinkAddress = "D:\Adobe_Designer_Forms\deluser.pdf"
ElseIf Me.Combo1.Value = "chang user" Then
Me.Command0.HyperlinkAddress = "D:\Adobe_Designer_Forms\disqual.pdf"
End If
End Sub
--
Thanks
Elyse
:
Elyse,
In the OnChange event of the combo box, set the hyperlink address property
of the button to the document you want opened, e.g.
me.Command89.HyperlinkAddress = "C:\OurDocuments\mypdf.pdf"
When the button is clicked, Windows will open the document using the program
defined by the file type or extension. You don't need the shell command.
Bruce
:
Hi,
I have created a combox object and would like for a user to be able to open
an Adobe PDF file when a selection in the combox is changed. Can I use
AppActivate or do I need to use a differnet method?
So far, I've used this, but it doesn't work
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Dim MyAppID, ReturnValue
MyAppID = Shell("D:\Adobe_Designer_Forms\deluser.pdf", 1)
AppActivate MyAppID
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub