How do I link back to a record from a reports results?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Microblitz
    New Member
    • Jul 2010
    • 40

    How do I link back to a record from a reports results?

    This is the senario;

    I have a database which creates a report of batch numbers occuring on a specific day.

    The form is linked to a report which returns the days on which a particular batch number occurs.

    I want to be able to click on a date in the report and filter the form according to the report.
    I have already created a clickable link (Hyperlink) in the report which is the date I want to link back to the main form as the filter.

    The code I currently have uses the following variables.

    [DateofTest] is the column in the record table
    Main is the form name
    DateOfTest is the created day that a searched for batch number occurs on in the report.

    Code:
    Private Sub DateOfTest_Click()
    DoCmd.OpenForm "Main", acNormal, , [DateOfTest] = Me.DateOfTest
    End Sub
    There are lots of examples of this code around but all deal with numbers or strings not datecodes, so Ive already been through the "Type mismatch" routine. This code doesnt freak but equally does'nt filter. The filter button is lit in the form "Main" but it displays all records.

    Where did I go wrong?
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    I'm using Access 2003 and I don't see an option to handle a Click event on a TextBox control within a report. Is this possibly a new feature?

    Comment

    • Microblitz
      New Member
      • Jul 2010
      • 40

      #3
      I'm using 2007 and there is a link to URL feature(It looks like this http://bytes.com/images/editor/createlink.gif ).Insert+K adds it on a control selected from the design menu. You then have an option to use the wizard or create your own event for it.

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        Yes, NeoPa, they added all kinds of nonsensical stuff to Reports in v2007, even Command Buttons!

        Makes absolutely no sense to me!

        Linq ;0)>

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32661

          #5
          Strange but True! eh.

          Your problem may be associated with your use of the date literal then. See Literal DateTimes and Their Delimiters (#).
          Code:
          Private Sub DateOfTest_Click()
          DoCmd.OpenForm "Main", acNormal, , "[DateOfTest]=" & Format(Me.DateOfTest, "\#m/d/yyyy\#")
          End Sub

          Comment

          • Microblitz
            New Member
            • Jul 2010
            • 40

            #6
            Good news everybody!(I admit to being a Futurama fan!)
            That works fine now.

            And I guess the reason some of the advanced controls are available to reports are that some people never print out a report anymore, they use it as a dashboard and want to tinker with the variables.

            Comment

            Working...