Results 1 to 4 of 4
  1. #1
    Beginner72 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Dec 2016
    Posts
    12

    Assigning a Hyperlink to a field in a form

    First off, I am newer to access and much newer to vba programming in access. I have a table of purchases and within the table there are fields for the vendor and for the invoice number. I also have a hyperlink field that that contains the file path to a scanned copy of the invoice. The file path is structured in such a way that path will lead to a folder named after the vendor and the file name is the invoice number. In my Purchases form where I enter new purchases I have tried to assign the path of the invoice to the field control called ImgPth. I can easily create the path name using a sub routine after the invoice number is updated. I am puzzled as to how I assign that address as a hyperlink. I thinking I maybe missing a function along the way. Here is my code



    Private Sub InvNumb_AfterUpdate()


    Dim varPath As String

    varPath = "path" & VendName & "" & InvNumb & ".bmp"


    ImgPth = varPath


    End Sub

    This works to supply the address name but I how do I set the path name (varPath) as the hyperlink address.

    Any help for this newbie would be greatly appreciated.

    Thanks in advance.

  2. #2
    Beginner72 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Dec 2016
    Posts
    12
    For some reason the backward slash is not showing up between the middle quotes in the varPath expression line.

  3. #3
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    varPath = "path" & VendName & "" & InvNumb & ".bmp"
    Where is "path" coming from and what does it look like? If it doesn't end in a slash, you either have to edit that source so that it does, or concatenate it into your constructed path string. I doubt it should have quotes around it as well. Also, InvNumb looks like an incomplete reference. Think of it as telling someone to meet you at Main Street. It might work sometimes, but it's flaky.

    Path is a reserved word and shouldn't be used in this way. This probably should look more like
    varPath = strPath & "" & Me.txtVendName & "" & Me.txtInvNumb & ".bmp" where (e.g.) txtVendName is the control on your form which contains part of the path string.
    You'd use Application.FollowHyperlink, but there are other (and some would say better) ways to open files. You might get security warnings using this method, which was (I think) originally designed to open web pages. If your file path may contain characters which would be problematic for this method, you should check out this code:
    http://allenbrowne.com/func-GoHyperlink.html
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Beginner72 is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Dec 2016
    Posts
    12
    Sorry, I am not using "path" in my code. I put it in there to represent the network path. For example the code actually looks similar to this - "c:\users\user\documents\..." The last folder would be represented by the vendor name and the file by the invoice number. I did learn of Application.Hyperlink which I have got working. Thanks for your response.

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

Similar Threads

  1. Hyperlink from field to form
    By adame in forum Access
    Replies: 4
    Last Post: 02-01-2017, 03:11 PM
  2. Replies: 2
    Last Post: 10-20-2016, 02:33 PM
  3. Replies: 2
    Last Post: 04-27-2016, 05:18 PM
  4. Replies: 9
    Last Post: 06-12-2014, 01:36 PM
  5. Replies: 3
    Last Post: 11-05-2013, 01:25 PM

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