Results 1 to 5 of 5
  1. #1
    Douglas Post is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Location
    Portage, MI
    Posts
    9

    Press a button to combine two fields to open a PDF

    I have a Button that I want to press to open a PDF. The path to the PDF is constructed from a table called
    [Listings] that contains part of a link in a field called [Property Root Folder] and then add the end part of the link in another table called [Valuations] with the field [Valuation Link]. The two tables have a relationship with the common field
    [ListingID]

    The code I wrote does not work, I think I am referencing the field incorrectly as I get a Run-time error '424' Object required....

    Private Sub BPO_Click()



    Dim r As Variant

    If Dir(Listings![Property Root Folder] & Me![Valuation Link], vbDirectory) <> "" Then
    r = Shell("Explorer.exe " & Listings![Property Root Folder] & Valuations![Valuation Link])

    End If

    End Sub

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    Why wopuld you open a pdf with explorer, why not
    "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe" or
    where ever you have it located.

    There is a sample by hansup (has more than you may need) at
    http://stackoverflow.com/questions/6...encing-a-field

  3. #3
    Douglas Post is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Location
    Portage, MI
    Posts
    9
    I don't want to specify a certain program as sometimes it is a PDF and other times the file could be a JPG.

    The structure of the database:

    DATA FROM THE FIRST TABLE
    TABLE: Listings
    FIELD: Property Root Folder ***This is a path like "C:\6850 Dustin Circle\"
    COMMON FIELD: Listing ID ***This is a Numeric Field)

    DATA FROM THE SECOND TABLE WHICH THE FORM IS BASED ON
    TABLE: Valuations
    FIELD: Valuation Link ***This is a file name like "10630 South 27th Street - BPO.PDF"
    COMMON FIELD: Listing ID

    This is what I have so far:

    Code:
    Private Sub BPO_Click()
       
    Dim r As Variant
    Dim strRootPath As String
    
    If Dir(Me![Valuation Link], vbDirectory) <> "" Then
        strRootPath = DLookup("Listings![Property Root Folder]", "Listings", "ListingID=ListingID")
        strRootPath = strRootPath & Me.[Valuation Link]
        
        Debug.Print strRootPath ' what does this show??
        
        r = Shell("Explorer.exe " & strRootPath)
        
    End If
    
    End Sub
    I receive no error and nothing appears to happen.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,848
    I don't see how this will work
    "ListingID=ListingID"
    What do you think this statement does/will do?
    If you are trying to get data from 2 tables, I'd suggest a query.

    Does your Debug.print produce anything?

    If you have a combo or other control in which you select or type a value, let's call it Me.ListingId
    then your
    strRootPath = DLookup("Listings![Property Root Folder]", "Listings", "ListingID=ListingID")
    could become
    strRootPath = DLookup("[Property Root Folder]", "Listings", "ListingID= '" & Me.ListingID & "'")

  5. #5
    Douglas Post is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2012
    Location
    Portage, MI
    Posts
    9

    Solved

    I solved the issue by creating a query and then using Dlookup to find the value I combined in the query. So basically a two step process.

    Thanks for putting me on the right track!

    Code:
    Private Sub BPO_Click()
    Dim strRootPath As String
    
          strRootPath = Nz(DLookup("[Valuation Path]", "Valuation Path", "
    [ListingID]&[ValuationID]=" & 
    [ListingID] & [ValuationID]))
          
        Application.FollowHyperlink strRootPath
    
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 0
    Last Post: 11-22-2011, 09:10 PM
  2. need to combine two fields
    By jwallace203 in forum Access
    Replies: 1
    Last Post: 07-29-2011, 07:11 PM
  3. open small popup form by press functional key
    By alex_raju in forum Access
    Replies: 0
    Last Post: 07-13-2011, 09:20 AM
  4. Replies: 0
    Last Post: 07-05-2011, 10:24 PM
  5. Combine two fields, Null fields involved
    By yes sir in forum Access
    Replies: 9
    Last Post: 10-03-2010, 09:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums