open specific .txt doc in access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to get a particular button on my form to open a specific notepad
text when clicked on. The VBA code looks something like this:

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?
 
Try

Dim strFolder As String
strFolder = "notepad.exe C:\Documents and Settings\ . . ."
x= Shell(strFolder & Me.ProposalID.Value & ".txt")
======================================
Or
Dim strFolder As String
strFolder = "C:\Documents and Settings\ . . ."
Application.FollowHyperlink strFolder & Me.ProposalID.Value & ".txt"
======================================
Its seems that you mixed both options
 
Don't you mean ?

Private Sub Notes_Click()
Const strFolder = "C:\Documents and Settings\ . . .\"
Shell "notepad.exe " & strFolder & Format(Me.ProposalID, "0") & ".txt",
vbNormalFocus

End Sub

Regards John
 
Neither is working. I don't understand where "x = Shell . . ." comes in at.
And am I really supposed to be typing Me.Proposal_ID.Value & ".txt" or should
value be replaced with something else. Also my notepad.exe is in the same
folder as my .txt files. Does that make a difference?

This is driving me nuts.
 
The error message reads, and I quote:
"The expression OnClick you entered as the event property setting produced
the following error:
Expected: Text or Binary
*The expression may not result in the name 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.
 
The error message reads, and I quote:
"The expression OnClick you entered as the event property setting produced
the following error:
Expected: Text or Binary
*The expression may not result in the name 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.
 
Since you've got spaces in your folder name, you need to put quotes around
the path:

Shell "notepad.exe " & Chr$(34) & strFolder & Format(Me.ProposalID, "0") &
".txt" & Chr$(34)


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


I.Candi said:
The error message reads, and I quote:
"The expression OnClick you entered as the event property setting produced
the following error:
Expected: Text or Binary
*The expression may not result in the name 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.

Douglas J. Steele said:
What error message might that be?
 
Private Sub Label78_Click()

Const strFolder = "C:\Documents and Settings\ . . . \Notes\"
Shell "notepad.exe" & Chr$(34) & strFolder & Format(Me.Proposal_ID, "0") &
".txt" & Chr$(34)

End Sub

Still getting same error message.

Douglas J. Steele said:
Since you've got spaces in your folder name, you need to put quotes around
the path:

Shell "notepad.exe " & Chr$(34) & strFolder & Format(Me.ProposalID, "0") &
".txt" & Chr$(34)


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


I.Candi said:
The error message reads, and I quote:
"The expression OnClick you entered as the event property setting produced
the following error:
Expected: Text or Binary
*The expression may not result in the name 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.

Douglas J. Steele said:
What error message might that be?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


I tried that too. I keep getting the same error message.

:

Don't you mean ?

Private Sub Notes_Click()
Const strFolder = "C:\Documents and Settings\ . . .\"
Shell "notepad.exe " & strFolder & Format(Me.ProposalID, "0") &
".txt",
vbNormalFocus

End Sub

Regards John

I am trying to get a particular button on my form to open a specific
notepad
text when clicked on. The VBA code looks something like this:

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?
 

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

Back
Top