By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,702 Members | 1,760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,702 IT Pros & Developers. It's quick & easy.

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

Microblitz
P: 40
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.

Expand|Select|Wrap|Line Numbers
  1. Private Sub DateOfTest_Click()
  2. DoCmd.OpenForm "Main", acNormal, , [DateOfTest] = Me.DateOfTest
  3. End Sub
  4.  
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?
Jul 19 '10 #1

✓ answered by NeoPa

Strange but True! eh.

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

Share this Question
Share on Google+
5 Replies


NeoPa
Expert Mod 15k+
P: 31,769
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?
Jul 19 '10 #2

Microblitz
P: 40
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.
Jul 19 '10 #3

missinglinq
Expert 2.5K+
P: 3,532
Yes, NeoPa, they added all kinds of nonsensical stuff to Reports in v2007, even Command Buttons!

Makes absolutely no sense to me!

Linq ;0)>
Jul 19 '10 #4

NeoPa
Expert Mod 15k+
P: 31,769
Strange but True! eh.

Your problem may be associated with your use of the date literal then. See Literal DateTimes and Their Delimiters (#).
Expand|Select|Wrap|Line Numbers
  1. Private Sub DateOfTest_Click()
  2. DoCmd.OpenForm "Main", acNormal, , "[DateOfTest]=" & Format(Me.DateOfTest, "\#m/d/yyyy\#")
  3. End Sub
Jul 19 '10 #5

Microblitz
P: 40
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.
Jul 20 '10 #6

Post your reply

Sign in to post your reply or Sign up for a free account.