Results 1 to 9 of 9
  1. #1
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hyperlink error (Access 2000)

    Using Access 2000

    I have placed a Hyperlink on a form, to open a report. The report prompts for a parameter. The report runs fine if there is data, but if there is no data I get the following message
    "Access can't follow the hyperlink to rptxxx. Please verify the destination."

    I have a message box that appears if there is no data in the report and that appears properly, but then the second error message shown above.

    I have tried placing various Error coding in the On Click event for the hyperlink label, but can't seem to find something that will make a difference.

    Any suggestions?

    Thanks.

    Tom

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

    Re: Hyperlink error (Access 2000)

    I don't think you can trap the error for a hyperlink. Instead of a hyperlink, use code in the On Click event procedure:

    Private Sub Something_Click()
    On Error GoTo ErrHandler

    DoCmd.OpenReport "rptMyReport", acViewPreview
    Exit Sub

    ErrHandler:
    If Err = 2501 Then
    ' Report canceled, we can ignore this, so do nothing
    Else
    MsgBox Err.Description, vbExclamation
    End Sub

    You must clear the Hyperlink SubAddress property to make this work.

  3. #3
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hyperlink error (Access 2000)

    Hans
    Thanks for your reply. That works just fine. But I wonder if you would offer some feedback on the issue which led me to post this question.

    I have a form which has an option group from which the user can select a report to preview or print. The trouble is there are 28 options in the group, so I have grouped them in logical groups and then added labels and dividing lines to make the form easier to visualize. But the option group doesn't contain the labels and dividing lines so they disappear as soon as an option is selected.

    That's what led me to thinking about the possibility of using Hyperlinks...which work just fine except in cases where there are parameters, and several of the possible reports have parameters.

    Combo or List boxes would be a possibility but a list of 28 reports wouldn't be that easy to wade through. I suppose I could place several, perhaps 5 or 6, list boxes on the form, and put labels above each list. But is it possible to disable the other list boxes if a selection is made in one...in order to prevent it appearing as if selections are being made in more than one box at the same time?

    Or is there a way to place several option groups on the same form, and disable the other groups if a selection is made in one of the groups?

    If you were doing this, how would you go about it?

    Thanks.
    Tom

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

    Re: Hyperlink error (Access 2000)

    Yes, you can place multiple option groups on one form. You can use the After Update event of combo boxes, list boxes and option groups to show/hide or enable/disable other combo boxes, list boxes and option groups, by setting their Visible or Enabled property.

    You can also limit the choices in a list box or combo box based on the item selected in another one: see ACC2000: How to Synchronize Two Combo Boxes on a Form.

  5. #5
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hyperlink error (Access 2000)

    Hans
    Another possibility, I suppose, would be to use Hyperlinks for the reports which require no parameter, and use your solution for those which do require a parameter.

    Tom

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

    Re: Hyperlink error (Access 2000)

    Yes, you can do that if you like.

  7. #7
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hyperlink error (Access 2000)

    Hans
    Thanks for your replies. Which do you consider to be the best approach in the long run?
    Tom

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

    Re: Hyperlink error (Access 2000)

    I don't think one approach is intrinsically better than the other. However, I wouldn't mix hyperlinks and DoCmd.OpenReport, for two reasons:
    - I don't like the Web toolbar that pops up if you follow a hyperlink. I know how to banish it, but I can't rely on all users knowing how to do that.
    - I prefer to present a consistent interface; since DoCmd.OpenReport works in all cases, I would use that.
    It is a matter of taste.

  9. #9
    4 Star Lounger
    Join Date
    Oct 2003
    Location
    Guelph, Ontario, Canada
    Posts
    428
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hyperlink error (Access 2000)

    Thanks, Hans. I appreciate your advice.
    Tom

Posting Permissions

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