Results 1 to 13 of 13
  1. #1
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Create a cmd button to open a hyperlink in lstbox (2003)

    Hi, I am having so problems creating a code that could open a record hyperlink in a query. The query that is the row source of the unbound list box has a LinkNo and has a field name LinkFile which is a hyperlink data type that possess the file. I Dont know how to fire up a file contain in a field of a query and open the perspective LinkNo. I need this button because when i double click the selected file in the list box it lets me edit the location of the file or update the data of the hyperlink by openning another form which also lets me see the file after clicking the hyperlink. I would like just view the file without opening the other form that fire up when i double click. Any help.

    Private Sub cmdViewHyperlink_Click()
    On Error GoTo Err_cmdViewHyperlink_Click

    If Me.lstHyperlinks.ListIndex > -1 Then
    ***********************************
    End If

    Exit_cmdViewHyperlink_Click:
    Exit Sub

    Err_cmdViewHyperlink_Click:
    MsgBox Err.Description
    Resume Exit_cmdViewHyperlink_Click

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Create a cmd button to open a hyperlink in lstbox (2003)

    Does this do what you want?

    Application.FollowHyperlink Me.lstHyperlinks

  3. #3
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Create a cmd button to open a hyperlink in lstbox (2003)

    That works perfectly. One problem I am having. I had to change the bound columm of the listbox to 4 which is where the Hyperlink file is located. I have also a delete buttom and the double click command in the list box which their bound columm is 1 the LinkNo so the command could be execute. I tried to use BoundColumm (4) after the Me.lstHyperlinks but it does not work. Any idea. Thanks for everything Hans.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Create a cmd button to open a hyperlink in lstbox (2003)

    Try

    Me.lstHyperlinks.Column(3)

    The column index is zero-bound, so 0 is the first column, and 3 is the fourth column.

  5. #5
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Create a cmd button to open a hyperlink in lstbox (2003)

    Excellent work!!. Thank you Hans.

  6. #6
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Create a cmd button to open a hyperlink in lstbox (2003)

    Recently the code it is not working. It only recognizes one the hyperlink files. I have 6 files displaying in the listbox. The 3rd file is opening up, the others have the runtime erro 490.

    Here is the code, I really dont know what is going on.

    Private Sub lstAttachments_DblClick(Cancel As Integer)

    If Me.lstAttachments.ListIndex > -1 Then
    Application.FollowHyperlink Me.lstAttachments.Column(3)

    End If

    End Sub

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Create a cmd button to open a hyperlink in lstbox (2003)

    Try adding a line temporarily to display the value:

    Private Sub lstAttachments_DblClick(Cancel As Integer)
    If Me.lstAttachments.ListIndex > -1 Then
    MsgBox Me.lstAttachments.Column(3)
    Application.FollowHyperlink Me.lstAttachments.Column(3)
    End If
    End Sub

    The code will display the item that FollowHyperlink will try to open. Can you detect a difference between the items that work and those that don't?

  8. #8
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Create a cmd button to open a hyperlink in lstbox (2003)

    The location of all the records are correct. When I go into the form that edit the hyperlink file if I click the hyperlink it will open up, but if I try the double click command in the list box to open the hyperlink directly without going to the edit form. It display the error 490. Also I when ahead and added a new file and it shows in the list box, I double click on it and it work perfectly. I use the MsgBox when it displayed the correct address for the hyperlink. I am going to delete the files that are not working and insert them again.

  9. #9
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Create a cmd button to open a hyperlink in lstbox (2003)

    I deleted all the old link files and added new ones, some were the previous pdf files other word doc. This process did not work either. only one pdf is openning. the rest of the documents have the error.

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Create a cmd button to open a hyperlink in lstbox (2003)

    Does the line

    MsgBox Me.lstAttachments.Column(3)

    really display the correct path and filename, and nothing extra before it or after it? No extraneous symbols?

  11. #11
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Create a cmd button to open a hyperlink in lstbox (2003)

    Here is the message. check the following doc.

    Edited by HansV to replace document with the picture it contained

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Create a cmd button to open a hyperlink in lstbox (2003)

    As you can see, the text contains more than just the path and file name. It is the way Access stores a hyperlink:

    display text#address#subaddress

    Try this:

    <code>Application.FollowHyperlink Split(Me.lstAttachments.Column(3), "#")(1)</code>

  13. #13
    2 Star Lounger
    Join Date
    Jul 2005
    Location
    North Carolina, USA
    Posts
    195
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Create a cmd button to open a hyperlink in lstbox (2003)

    Hans, You're the best. It works perfectly. You are the guru.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •