Access 2007 VB programming

Discussion in 'OT Technology' started by drake, Oct 16, 2007.

  1. drake

    drake OT Supporter

    Joined:
    Jul 10, 2002
    Messages:
    4,622
    Likes Received:
    3
    Location:
    East Bay
    I have an entry that I want to link to a pdf file, so that when I click a button the pdf file associated with the entry will open. Is there any way to do this?

    So far I've found this, but it doesn't seem to work:
    Code:
    Private Sub Open_PDF_Click()
     '// open file (quotes are used so that the actual value that is passed is "C:\test.doc"
     
        ShellExecute 0, vbNullString, """"C:\test.doc"""", vbNullString, vbNullString, vbNormalFocus
        
    End Sub
    The file location is a field that is not in the form view, so instead of pointing to a location like "C:\" I want to point it to a field on that entry with the file location :hsd:
     
  2. drake

    drake OT Supporter

    Joined:
    Jul 10, 2002
    Messages:
    4,622
    Likes Received:
    3
    Location:
    East Bay
    Well, I seem to have found a solution :cool:

    One of my first attempts with Access so I don't know if could be done better, since I really wasn't sure of what it was called that I actually wanted to do. Also, since acrobat reader is installed on the computer, there was no need to get into the shell.

    Code:
    Option Compare Database
    Option Explicit
    Private Sub Open_PDF_Click()
        
    Application.FollowHyperlink [i]your text field name[/i]
    
    End Sub
     
  3. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    I was going to say, you should be able to make the field a hyperlink field and it will open whatever document you have linked there
     
  4. drake

    drake OT Supporter

    Joined:
    Jul 10, 2002
    Messages:
    4,622
    Likes Received:
    3
    Location:
    East Bay
    Yeah, I figured that it should be easy but I don't know any VB and haven't even used Access before :hsugh: Just getting started messing around with it for work.
     

Share This Page