Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2003
    Location
    New York
    Posts
    47

    Unanswered: Inserting a hyperlink

    I have code that saves a copy of a report as a word doc on the network but I need to put a hyperlink to it in the record. Currently, all I am able to do is put the text for the hyperlink in, not an actual working link. Help??? I am working in Access 2003 if it make a difference.
    Terri Gavin

  2. #2
    Join Date
    May 2010
    Posts
    601
    EDIT - deleted reply
    Last edited by HiTechCoach; 06-20-10 at 20:23. Reason: Change ideas
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  3. #3
    Join Date
    Dec 2003
    Location
    New York
    Posts
    47
    This is how the document is being saved...

    DoCmd.OutputTo acOutputReport, stDocName, acFormatRTF, Forms![frmContacts]![txtLName] & ", " & Forms![frmContacts]![txtFName] & " " & Format(Date, "m-d-yyyy") & ".doc", True
    Terri Gavin

  4. #4
    Join Date
    May 2010
    Posts
    601
    Quote Originally Posted by tgavin View Post
    I have code that saves a copy of a report as a word doc on the network but I need to put a hyperlink to it in the record. Currently, all I am able to do is put the text for the hyperlink in, not an actual working link. Help??? I am working in Access 2003 if it make a difference.
    How are you inserting the link? Please post the code.

    I find the hyperlink field is best for Web Site URLs.

    See if this helps:

    Document links
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  5. #5
    Join Date
    May 2010
    Posts
    601
    Quote Originally Posted by tgavin View Post
    This is how the document is being saved...

    DoCmd.OutputTo acOutputReport, stDocName, acFormatRTF, Forms![frmContacts]![txtLName] & ", " & Forms![frmContacts]![txtFName] & " " & Format(Date, "m-d-yyyy") & ".doc", True
    This is actually saving in RTF format. I would not use the .doc extension, but the more accurate .RTF.

    DoCmd.OutputTo acOutputReport, stDocName, acFormatRTF, Forms![frmContacts]![txtLName] & ", " & Forms![frmContacts]![txtFName] & " " & Format(Date, "m-d-yyyy") & ".rtf", True
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  6. #6
    Join Date
    Dec 2003
    Location
    New York
    Posts
    47
    But is that going to help me create the hyperlink. As I said, I can get the text in there but I am not sure how to get the actual hyperlink there.
    Terri Gavin

  7. #7
    Join Date
    May 2010
    Posts
    601
    The first time I read your post I took it as that you were wanting o insert a hyper link on the document. I had recently done this. When I first replied, I was thinking this is what you wanted.

    After re-reading your post, I realized that what you probably were wanting to do is save a link to the document you just created in the related record int he database. That is why I delete my first reply. By then you had already answered.

    So now to saving a link in a hyperlink data type.


    Hyperlink Property
    See AlsoApplies ToExampleSpecificsYou can use the Hyperlink property to return a reference to a Hyperlink object. You can use the Hyperlink property to access the properties and methods of a Hyperlink object associated with a command button, image, or label control. Read-only.

    expression.Hyperlink
    expression Required. An expression that returns one of the objects in the Applies To list.

    Remarks
    The Hyperlink property is available only by using Visual Basic.

    Example

    The CreateHyperlink procedure in the following example sets the hyperlink properties for a command button, label, or image control to the address and subaddress values passed to the procedure. The address setting is an optional argument, because a hyperlink to an object in the current database uses only the subaddress setting, To try this example, create a form with two text box controls (txtAddress and txtSubAddress) and a command button (cmdFollowLink) and paste the following into the Declarations section of the form's module:

    Private Sub cmdFollowLink_Click()
    CreateHyperlink Me!cmdFollowLink, Me!txtSubAddress, _
    Me!txtAddress
    End Sub

    Sub CreateHyperlink(ctlSelected As Control, _
    strSubAddress As String, Optional strAddress As String)
    Dim hlk As Hyperlink
    Select Case ctlSelected.ControlType
    Case acLabel, acImage, acCommandButton
    Set hlk = ctlSelected.Hyperlink
    With hlk
    If Not IsMissing(strAddress) Then
    .Address = strAddress
    Else
    .Address = ""
    End If
    .SubAddress = strSubAddress
    .Follow
    .Address = ""
    .SubAddress = ""
    End With
    Case Else
    MsgBox "The control '" & ctlSelected.Name _
    & "' does not support hyperlinks."
    End Select
    End Sub


    As you can see, using the hyperlink data type is not easy. I find i better to use a text field. See the link in post #4.

    How are you inserting the link? Please post the code.
    Last edited by HiTechCoach; 06-21-10 at 14:46.
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  8. #8
    Join Date
    Dec 2003
    Location
    New York
    Posts
    47
    Thanks Boyd, your second assumption is right. I found the code you sent when searching earlier but unfortunately my code knowledge is not good enough for me to understand what it is saying and how to adjust it for my circumstance. I am afraid I have learned the code I know from adjusting wizard code, help, trail and error, and the generous assistance of guys like you on this form and MS (which seems to have disappeared??)

    What I put in the code was

    [Forms]![frmMatter]![sfrmActivity-Matter].[Form]![hypDocument] = "C:\Documents and Settings\Terri Gavin\Desktop\Desktop\MDM\" & [Footer]

    which put the text in but not the link. It was one of the reasons I was using the code to insert the info on the Activity form about the letter instead of an append query (prior post you answered today).

    Again, help is greatly appreciated. Thanks.
    Terri Gavin

  9. #9
    Join Date
    May 2010
    Posts
    601
    Quote Originally Posted by tgavin View Post
    Thanks Boyd, your second assumption is right. I found the code you sent when searching earlier but unfortunately my code knowledge is not good enough for me to understand what it is saying and how to adjust it for my circumstance. I am afraid I have learned the code I know from adjusting wizard code, help, trail and error, and the generous assistance of guys like you on this form and MS (which seems to have disappeared??)

    What I put in the code was

    [Forms]![frmMatter]![sfrmActivity-Matter].[Form]![hypDocument] = "C:\Documents and Settings\Terri Gavin\Desktop\Desktop\MDM\" & [Footer]

    which put the text in but not the link. It was one of the reasons I was using the code to insert the info on the Activity form about the letter instead of an append query (prior post you answered today).

    Again, help is greatly appreciated. Thanks.
    Terri,

    As you can see from the code in my last post, working with the Hyperlink data type in a table is not as simple as just a plain text data type. You code will work great is it was just text. That is why the example I posted does not use a Hyperlink data type, but just a text field. It is a lot easier use.

    If you want to stick with using the Hyperlink data type in the field, you will need to use some VBA code similar to the example code in my last post. give it a try. If you can't get it to work, then I would suggest that you post a database with a sample of your form and any other objects requires to make it work. Remember to remove any confidential data and only include sample data.
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

Posting Permissions

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