Embedding Reports on to Forms, is it still possible? (1 Viewer)

christopherjoubert

New member
Local time
Today, 12:04
Joined
Jul 14, 2023
Messages
6
I have found two necroposts about this subject dating back to 2004

What I Am wondering is it still possible, and how to go about as this method doesn't seem to function properly?

What I have is an inventory control database, and the end users need to look up devices, etc. the previous version of the database simply loads the report in print preview, which is fine, and if there is no way to fix that I will let it be, but I'd rather have the report show up on a subform embedded into the form that controls the entire reporting functions, which report, what filters, etc.

And I've had no luck finding anything via google,

I've tried setting the subform SourceObject via vba to open the reports, the code runs but of course nothing seems to happen.
The idea isn't to embed a specific report, but to allow the option to open any of the dozen reports on a single page in a similar view.

Anyone have any suggestions?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:04
Joined
Feb 28, 2001
Messages
27,187
I did a search on "subreports" in Access and found several links to include MS documentation and some videos. This is what Microsoft has to say.


It specifically suggests that you can put a sub-form on a report but didn't discuss the converse case. Nonetheless, I think it is a matter of getting the right control for the job. But following up on the topic, I found some non-conclusive but direct evidence that it depends on which version of Access you are using.


It seems that Ac2007 doesn't allow it. Didn't say anything about other versions that disallowed it, but did say that Ac2010, Ac2013, and Ac2016 DO allow it. I'm going to guess that versions newer than Ac2016 would also allow it.
 

isladogs

MVP / VIP
Local time
Today, 17:04
Joined
Jan 14, 2017
Messages
18,227
Yes its possible to have a report as a subform or a form as a subreport. However, not all functionality will available in either setup.
No need to use SourceObject. Just drag the report onto the form to embed it in report view
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:04
Joined
Oct 29, 2018
Messages
21,473
Doc made a good point. Which version of Access are you using?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:04
Joined
Feb 28, 2001
Messages
27,187
OK, if there is a sub-form/report control on the form, it would be possible to dynamically load the report name to the appropriate control property, which I believe is called .SourceObject; this is the NAME of the report. Because this is required to be a name, it means the report has to exist already and be stored as a formal object among the other reports listed in the navigation pane. So build the sub-report and save it.

The NORMAL way to open a sub-anything is to have it already defined among the other controls by the time you open the containing object, but you want that kept empty to support your design goal. Therefore that report won't necessarily open automatically. I.e. the "normal" event that would open it is now passed. Therefore you might have to "tickle" it by issuing an explicit open command. Since I've not tried this in a long time, I'm not sure of the details but it should be possible. I'm sure my colleagues could fill in some blanks. I have to leave for a while and don't have time to research it now, but I'm sure some of my colleagues here on the forum can point you in the right direction.

I was able to find a reference for dynamically loading the .SourceObject.

 

isladogs

MVP / VIP
Local time
Today, 17:04
Joined
Jan 14, 2017
Messages
18,227
@theDBguy & @The_Doc_Man I am using Access 2019.

@isladogs the problem with using the drag method is it doesn't allow the endusers to change which report is showing, it will always show that one report.
Not sure whether you can get the SourceObject approach to work as I haven't tried
However you could drag each of the reports onto the form then make them all hidden
Then use the buttons to make one report visible at a time e.g.

Code:
Private Sub Command2_Click()
    Me.rptObjects.Visible = True
    Me.rptReferenceInfo.Visible = False
End Sub

Private Sub Command3_Click()
    Me.rptObjects.Visible = False
    Me.rptReferenceInfo.Visible = True
End Sub

That will definitely work.
However, personally I'd stick to the approach you have now!
 

christopherjoubert

New member
Local time
Today, 12:04
Joined
Jul 14, 2023
Messages
6
I was finally able to get the reports to embed. I did this by creating a subreport control on the form, had to drag and drop a report then delete the SourceObject in order to give me an Unbound subreport, as otherwise it always defaulted to subform. It was giving me an issue, then I restarted Access and it started working, and has been consistent since. Now I just need to figure out filtering.

Thanks to everyone who got me this far, it was a combination of the links you all managed to find, that I was unable to and other ideas tossed in there.

On to figuring out the Filtering issue, will of course take any advice on that.
 

Users who are viewing this thread

Top Bottom