I use this code to open a txt file in access:
VB Code:
  1. Private Sub cmdViewFile_Click()
  2. Dim retval As Variant
  3. Dim strpath As String
  4. strpath = "c:\logfile.txt"
  5. retval = Shell("C:\winnt\system32\notepad.exe" & " """ & strpath & """", vbNormalFocus)
  6. End Sub
I will be giving some co-workers access to this db and not everyone has NT so the path of Notepad will be different.

What I have done is created a field for FilePath that holds the path of the associated file. I would like to code the button to use that field as the full path and when clicked use the systems default viewer to open it.

I use this in my vb app;

VB Code:
  1. ShellExecute Me.hwnd, vbNullString, File1.path & "\" & sName, vbNullString, "c:\", SW_SHOWNORMAL
But I am new to VBA!
P.S. I have searched this forum and the access forums I use but something similar to what I already have is all I've gotten.


I hope I was clear and I hope someone can help!?!

JO