• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 713
  • Last Modified:

Access 2010 Report as Source Object in Access Form

I have a form which contains a subform control. The SourceObject of the subform control is a report. The code in the Detail Format event of the report does not execute. Of course, if I run the report on its own, the code executes as planned. Is there a way to get code to execute in this scenario?
0
TechMommy
Asked:
TechMommy
  • 7
  • 3
  • 2
  • +1
1 Solution
 
Dale FyeCommented:
Alison,

Although I cannot recall ever putting a report into a subform control, I'm guessing that when you do, Access uses the ReportView as opposed to the PrintPreview, and a lot of the events in the report don't fire properly in ReportView.

Have you tried manipulating the report behavior from within the main form?
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>The SourceObject of the subform control is a report.
Even if this is possible, I highly recommend against it, as the properties of a report are different than a form.   For starters, reports are optimized to be printed on paper and with no user interface abilities, so none of the UI capabilities will work here.

Better to create a separate for to act as the subform.
0
 
TechMommyAuthor Commented:
I have never had a problem displaying a report in a form. It is a great way for a user to get a quick preview of how their data with be represented in the output. As an example you could have a preview of an invoice showing how the data entry will impact the printed invoice.

Also, manipulating the report behavior from within the main form doesn't work well.

Any additional thoughts or ideas?
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Sounds like ... this could be a limitation when using a Report in a Form ?
As a test - does code in *any* event in the Report execute ?

mx
0
 
TechMommyAuthor Commented:
The open event is the only code that runs. But, when you try to set the Visible property of a text box in the Detail section (for example), it doesn't exist, so the code doesn't execute (Object cannot be found).
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Just curious also ... what if this was a subReport in another Report (even if just a blank report). Does the Detail Section code execute then ?

mx
0
 
TechMommyAuthor Commented:
Yes, the code executes fine if it is a subreport in another report.
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Is this the first time you have tried this, or is it just not working in this instance ?
0
 
TechMommyAuthor Commented:
This is the first client that has needed code to execute in the subreport. I've used subreports in forms numerous times, but have just not encountered this specific situation before.
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
The only time I ever had to write VBA code in a subreport is to pull off the alternating greybars, before whatever Access version came out with the Alternate Back Color.

Any manipulation of columns (say last_name comma first_name) I was able to pull off in the query that fed your subreport.

So .. tell us what task dictates VBA code behind 'code to execute in the subreport'.
0
 
TechMommyAuthor Commented:
The user is requesting that they can view an invoice (report) from within a form. That way they can modify data in the form and preview how the printed invoice will appear. They want to hide and show different controls on the report based on the data in each detail line of the report.
0
 
TechMommyAuthor Commented:
I was never able to solve this problem. Unfortunately none of the comments helped me. I had to preview the subreport as a report. The users weren't happy, but the code executes as planned.
0
 
TechMommyAuthor Commented:
Since I did not receive a viable solution, or any particularly helpful comments, I had to abandon what I was trying to accomplish.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 7
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now