Link to pdf file within access (1 Viewer)

rhett7660

Still Learning....
Local time
Today, 00:12
Joined
Aug 25, 2005
Messages
371
Hello..

Here is what I would like to do. I have a folder say with 100 pdf's. What I would like to do is from an access folder be able to point to the specific pdf and have it create a link within the access form to the pdf they point to... Does this make sense?

Is there a way from within an access form that you can have a button that lets the end user look in a folder and select the pdf... and then create and store the link in an access form???

Thanks
R~
 

rhett7660

Still Learning....
Local time
Today, 00:12
Joined
Aug 25, 2005
Messages
371
Darn it.. I did a search and your thread did not come up.. of course I probably wasn't using the correct wording.. and of course I was also looking to do something other then just browse.... So I could of missed your thread...

Question:

If I do the import part I don't want to import the whole file I just want it to create a link and store that link in a field in the database? So on the form they will have the link displayed and they can either a: click on open file etc.... Does this make sense?

http://www.access-programmers.co.uk/forums/showthread.php?t=97787

Thank you very much for the file......

R~
 
Last edited:

ghudson

Registered User.
Local time
Today, 03:12
Joined
Jun 8, 2002
Messages
6,195
Yes. Just save the value in the tbFile text box to the field that you want to store the file info "value" for the current record.
 

rhett7660

Still Learning....
Local time
Today, 00:12
Joined
Aug 25, 2005
Messages
371
Thanks again...

How would I go about doing that? What part of the code would I need to change.. Don't know VB that well... Would you mind showing me the code I would need to put in??

Thanks
R~
 

ghudson

Registered User.
Local time
Today, 03:12
Joined
Jun 8, 2002
Messages
6,195
Code:
YourField = tbFile

You just need to run it from an event of your choosing. You could run it at the end of the code when the Browse button is clicked. Or create a new command button and run it in the OnClick event of you button.
 

rhett7660

Still Learning....
Local time
Today, 00:12
Joined
Aug 25, 2005
Messages
371
Ok I am looking at this code..... this is on the fFindOpenImportFile form.... under the browse command button under the event procedure for "On Click"

Code:
Private Sub bBrowse_Click()
On Error GoTo Err_bBrowse_Click
   
    Dim strFilter As String
    Dim lngFlags As Long
    Dim varFileName As Variant

    Me.tbHidden.SetFocus

'   strFilter = "Access (*.mdb)" & vbNullChar & "*.mdb" _
'    & vbNullChar & "All Files (*.*)" & vbNullChar & "*.*"
'    strFilter = "Access Files (*.mdb)" & vbNullChar & "*.mdb*"
    strFilter = "All Files (*.*)" & vbNullChar & "*.*"

    lngFlags = tscFNPathMustExist Or tscFNFileMustExist Or tscFNHideReadOnly

    varFileName = tsGetFileFromUser( _
    fOpenFile:=True, _
    strFilter:=strFilter, _
    rlngflags:=lngFlags, _
    strInitialDir:="C:\Windows\", _
    strDialogTitle:="Find File (Select The File And Click The Open Button)")
    'remove the strInitialDir:="C:\Windows\", _ line if you do not want the Browser to open at a specific location

    If IsNull(varFileName) Or varFileName = "" Then
        Debug.Print "User pressed 'Cancel'."
        Beep
        MsgBox "File selection was canceled.", vbInformation
        Exit Sub
    Else
        'Debug.Print varFileName
        'tbFile = varFileName
       
    End If

    Call ParseFileName

Exit_bBrowse_Click:
    Exit Sub

Err_bBrowse_Click:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_bBrowse_Click

End Sub


Where in the code would you put this? I created a new field in the tFiles table named "TestPath". My goal would be.. when the person locates the file..it just puts the link to where the file is inthe TestPath field in the database..

I am a little lost at this point.. Thank you for your help..

R~
 

bonekrusher

Registered User.
Local time
Today, 00:12
Joined
Nov 19, 2005
Messages
266
Here is another way to open the file and control the PDF

Code:
Private Sub Command5_Click()
    Dim AcroApp As CAcroApp
    Dim AVDoc As CAcroAVDoc
    Dim PDDoc As CAcroPDDoc
    Dim mypath As String
    Dim mystring As String
    Dim pg As Integer
    
 
     'you'll need to change this to an existing pdf file on your system
    mypath = "C:\Filename.pdf"
     
    Set AcroApp = CreateObject("AcroExch.App")
    Set AVDoc = CreateObject("AcroExch.AVDoc")
     
    AVDoc.Open mypath, ""
    Set PDDoc = AVDoc.GetPDDoc
     
    If IsNull(Me.Jumpto) Then
    MsgBox ("enter a page to jump to")
    Else:
        pg = Me.Jumpto - 1

    AVDoc.GetAVPageView.GoTo pg 'put whatever page you wanna goto there but keep in mind
' that page 1 is 0
    AcroApp.Show
End If
 

ghudson

Registered User.
Local time
Today, 03:12
Joined
Jun 8, 2002
Messages
6,195
rhett7660 said:
Where in the code would you put this? I created a new field in the tFiles table named "TestPath". My goal would be.. when the person locates the file..it just puts the link to where the file is inthe TestPath field in the database..
R~
At the end of the bBrowse_Click sub put this in to copy the value from the tbFile text box to your tbTestPath text box. Ensure that the name of the TestPath text box is prefixed with something like tb ot txt and not named the same as the field in your table for that would confuse Access.

Code:
tbTestPath = tbFile
 

rhett7660

Still Learning....
Local time
Today, 00:12
Joined
Aug 25, 2005
Messages
371
ghudson

Ok I have done what you said... It is still not working correctly. Do I need to also create another text box? Because this one is not working. As you can see I am a new to the vb thing...

R~
 

ghudson

Registered User.
Local time
Today, 03:12
Joined
Jun 8, 2002
Messages
6,195
I can not guess. If you post your db I will take a look at it. Just remove all the stuff not related to the problem, compact the db, zip up the db then attach it to a reply post.
 

Users who are viewing this thread

Top Bottom