Go Back   Access World Forums > Microsoft Access Discussion > Queries

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-15-2019, 10:44 PM   #1
GoodyGoody
Newly Registered User
 
Join Date: Aug 2019
Posts: 33
Thanks: 15
Thanked 0 Times in 0 Posts
GoodyGoody is on a distinguished road
What Report level fields are available to the 'On Print' event

Hi, I have a query with a number of columns that aren't printed on the report line but that I was to save to table for each line on the report. In the 'On Print' event I can successfully pick up this particular field (Me.RaceEventID as it happens) from the drop down that appears so Access VBA knows it's in the collection but when I actually run the report VBA gives an error saying it can't field the field Me.RaceEventID. I'd like to know why this is and so is the only work around to 'print' the field on the line but to hide it for printing to to make it explicitly visible to the 'On Print' event? Thanks as usual for any help.
Stephen

GoodyGoody is offline   Reply With Quote
Old 09-15-2019, 10:50 PM   #2
Gasman
Enthusiastic Amateur
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 4,105
Thanks: 421
Thanked 753 Times in 731 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: What Report level fields are available to the 'On Print' event

Me refers to the form or report.?
That control is not on your report.?
__________________
Access novice. Sometimes trying to give something back.
Access 2007

Please, please use code tag # when posting code snippets

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
Old 09-16-2019, 07:21 AM   #3
GoodyGoody
Newly Registered User
 
Join Date: Aug 2019
Posts: 33
Thanks: 15
Thanked 0 Times in 0 Posts
GoodyGoody is on a distinguished road
Re: What Report level fields are available to the 'On Print' event

It's all referring to controls on the Report. The Me.RaceEventID field is on the query and is available to the collection within VBA as I can select it in VBA when I type me.etc . It is not explictly anywhere on the report yet hence my suspicion that I need to actually put it in the detail line and hide it so it is available to VBA. But then when I run it it comes up with an error and when I debug it, it says field not found. Thanks
Stephen

GoodyGoody is offline   Reply With Quote
Old 09-16-2019, 08:29 AM   #4
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 6,419
Thanks: 162
Thanked 1,734 Times in 1,704 Posts
Minty is a jewel in the rough Minty is a jewel in the rough Minty is a jewel in the rough
Re: What Report level fields are available to the 'On Print' event

On a report the fields have to be present to be able to refer to them, unlike a form.

I suspect it's to do with the reports ability to group and total fields on the fly which could get messy if they were only in the underlying query, as the grouping wouldn't have taken place at that point.
__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
The Following User Says Thank You to Minty For This Useful Post:
GoodyGoody (09-21-2019)
Old 09-16-2019, 08:40 AM   #5
theDBguy
I’m here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 4,784
Thanks: 50
Thanked 1,090 Times in 1,071 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: What Report level fields are available to the 'On Print' event

Hi Stephen. Just curious, would you still get an error if you used bang instead of dot? For example: Me!RaceEventID
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
GoodyGoody (09-21-2019)
Old 09-16-2019, 09:02 AM   #6
jdraw
Super Moderator
 
jdraw's Avatar
 
Join Date: Jan 2006
Location: Ottawa, Ontario, Canada;West Palm Beach, Florida
Posts: 12,144
Thanks: 82
Thanked 2,010 Times in 1,958 Posts
jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light jdraw is a glorious beacon of light
Re: What Report level fields are available to the 'On Print' event

Stephen,

Can you post a copy of the database so readers can "experience" the issue?
We only need enough data to highlight the issue. You can anonymize a few records if there is some confidentiality involved.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jdraw is offline   Reply With Quote
Old 09-21-2019, 06:21 AM   #7
GoodyGoody
Newly Registered User
 
Join Date: Aug 2019
Posts: 33
Thanks: 15
Thanked 0 Times in 0 Posts
GoodyGoody is on a distinguished road
Re: What Report level fields are available to the 'On Print' event

Hi All, thanks for the replys. AS I suspected, it's because on a report the Query fields are available to the Collection but not the OnPrint event unless explcitly declared as Minty above said to. Thanks for the feedback. BTW, me!RaceEventID doesn't work either. Thanks again S

GoodyGoody is offline   Reply With Quote
Old 09-21-2019, 06:32 AM   #8
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,165
Thanks: 15
Thanked 1,576 Times in 1,498 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: What Report level fields are available to the 'On Print' event

Minty got it almost right.

In a Report, unlike a form, if you want to reference a field from the RecordSource in code, you must bind it to a control. You can make the control tiny and hidden but the field MUST be bound to a control to be available later. The reason is that Access is smarter than we are and for a report, it rewrites our query and substitutes its own version which includes ONLY the fields that are actually bound to controls. This is also why you can't rely on sort order in your RecordSource query but MUST use the Report's own sorting and grouping options to impose a sort order.
__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
The Following 3 Users Say Thank You to Pat Hartman For This Useful Post:
Gasman (09-21-2019), GoodyGoody (09-21-2019), Minty (09-23-2019)
Old 09-21-2019, 06:37 AM   #9
GoodyGoody
Newly Registered User
 
Join Date: Aug 2019
Posts: 33
Thanks: 15
Thanked 0 Times in 0 Posts
GoodyGoody is on a distinguished road
Re: What Report level fields are available to the 'On Print' event

thanks for the explanation Pat Hartman. I do like to know why things are happening. Makes it much easier to remember for next time.
GoodyGoody is offline   Reply With Quote
Old 09-22-2019, 01:32 PM   #10
Pat Hartman
Super Moderator
 
Join Date: Feb 2002
Location: Stratford,Ct USA
Posts: 28,165
Thanks: 15
Thanked 1,576 Times in 1,498 Posts
Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all Pat Hartman is a name known to all
Re: What Report level fields are available to the 'On Print' event

You're welcome

__________________
Bridge Players Still Know All the Tricks
Pat Hartman is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Report Print event? sja13 Modules & VBA 5 12-15-2017 09:38 AM
Graphics - print event in Access report or Excel max1 Reports 4 08-29-2015 09:18 PM
Close Event to Print Report velcrowe General 1 06-30-2006 09:08 AM
Report Event procedures not firing when directly print GumbyD Reports 3 08-17-2004 10:13 AM
Simple code for 'OnLoad' event to print a report nicktheblue Modules & VBA 2 10-19-2001 05:19 AM




All times are GMT -8. The time now is 05:55 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World