OK. This is exactly what I have in VB (where 'Notes' is no longer a button
on the form but a hyperlink:
Private Sub Label78_Click()
Dim strFolder As String
strFolder = "C:\Documents and Settings\ . . . \Notes\"
Application.FollowHyperlink strFolder & Me.Proposal_ID.Value & ".txt"
End Sub
And this is the error message I'm getting:
The expression OnClick you entered as the event property setting produced
the following error:
Expected Text or Binary.
*The expression of a macro, the name of a user-defined function, or [Event
Procedure].
*There may have been an error evaluating the function, event, or macro.
John Nurick said:
What I suggested was:
Dim strFolder As String
...
strFolder = "C:\Folder where my files are\"
Application.FollowHyperlink strFolder & Me.txtID.Value & ".txt"
You've inserted "notepad.exe" in two places where it doesn't belong. The
"Application" in Application.FollowHyperlink refers to the Access
Application object, not to the application you want to open, and all
that's needed for the hyperlink is the path to the file, e.g.
C:\Documents and Settings\ICandi\My Documents\XXX\1001.xls
On Mon, 23 Jan 2006 13:50:06 -0800, "I.Candi"
This is what I have in VB:
Private Sub Notes_Click()
Dim strFolder As String
strFolder = "notepad.exe C:\Documents and Settings\ . . ."
notepad.exe.FollowHyperlink strFolder & Me.ProposalID.Value & ".txt"
But I can't get it to work. For example, if the user is in the record with
Proposal ID 1001, I want them to be able to click on notes and the
corresponding .txt file (1001.txt) should open. What am i doing wrong?
:
There's no need to use RunApp.
If Notepad is the default text editor, or if you're happy to have the
file open in the user's default text editor, you can just use something
like this:
Dim strFolder As String
...
strFolder = "C:\Folder where my files are\"
Application.FollowHyperlink strFolder & Me.txtID.Value & ".txt"
(where txtID is the name of the textbox that's displaying the ID
number).
If you want to use Notepad even if it's not the user's preferred editor,
use the VBA Shell() function, something like this:
Shell "Notepad.exe """ & strFolder & Me.txtId.Value & ".txt"""
On Fri, 20 Jan 2006 08:59:04 -0800, "I.Candi"
I'm opening a notepad (.txt) using the RunApp in my forms Macro. How can I
get this particular button to open the corresponding .txt file? e.g. the
record with ID # 1003 should open 1003.txt when this button is clicked on. Is
this possible?