Change the origin of multiple subreports in the same report (1 Viewer)

zelarra821

Registered User.
Joined
Jan 14, 2019
Messages
819
Hello.

I need your help.

I need to create a report with multiple subreports, but have the source of these subreports dynamically set to a value.

Let's see if I can explain it, because with what I've told you so far I'm sure your brain has exploded.

The report I need to create is a balance sheet. There are categories of expenses and income. This is the scheme:

Gastos:

Horas
Insumos
Inversiones

Ingresos:

Cosecha
Indemnizaciones
Subvenciones

Since each of these categories has to show different data that it does not share with others, I need to make subreports for each category (I leave you a diagram of which fields go in each category).

So, in the main report I have set the Id of each of the categories as the origin. So what I was trying to achieve now is for each category to show the respective subreport.

I don't know if I've managed to explain it better now or if someone is hating my guts for not being able to express what I want to do.

Please, I need help to solve this. Any suggestion or contribution will be welcome.

I attach the database and the diagram of which fields go into each category, so you can see that, indeed, I have to create different subreports so as not to complicate things further.

Thank you so much.
 

Attachments

  • Balance.jpg
    Balance.jpg
    225.8 KB · Views: 59
  • Database.accdb
    Database.accdb
    5.9 MB · Views: 65
I noticed you don't have a control with IdPrincipal in your IBalance report so your Select Case statment cannot run. Add a textbox control using IdPrincipal as a Control Source. The rest is all in a foreign language which I cannot read.
 
Hi. Thanks for the answer.

I added a textbox using IDPrincipal as a Control Source in main report and all the subreports, but it doesn't work. I tested Select Case in on format event of detail section and on load of main report but I don't even get it to work.

So, if someone could give some advice, I'm glsd to test it.
 
I believe I have it working for you to test. Please see the new code in the CmdVerInforme On Click Event on the form FDialagoBalance in the attached file. I needed to set the subreports Source Object in the reports Design mode first, then open the report in Print Preview.

Using the reports On Format will not set the subreports Source Object.
 

Attachments

Hello, thank you very much for contributing.

I tell you. It's not your fault, but mine, for not translating the database, but a hell of a job. Anyway, you have used the dialog to open the report. In this you have added a Select Case for LstFincasAsignadas. However, the values in this list box have nothing to do with the PrincipalId.

So that you understand me, forget about the dialogue and focus only on the reports.

All reports originate from the TInforme table.

In the main report, what I do is extract the unique PrincipalIds, which will be the ones that will be associated through that PrincipalId with each and every one of the subreports, depending on whether one PrincipalId or another appears. All six may appear, or only two may appear.

I don't know if I have managed to explain myself.
 
OK so you want to be able to show one or multiple subreports on the same main report based upon which IdPrincipal numbers are chosen on the LstFincasAsignadas list. So if 2 is on the list alone, then the subreport IBalanceSubinformeHoras is shown. But if 2 and 3 are chosen, then the subreports IBalanceSubinformeInsumos and IBalanceSubinformeHoras are both shown on the report.

Is that correct? Like this:
1710885210876.png
 
Last edited:
The list box refers to farms. This database is to run an olive grove management company. Therefore, the user will enter expenses and income for each of the farms. Hence the list box, to filter by the properties.

Then, the PrincipalId refers to the categories it may have: inputs, hourly work, harvest, compensation, subsidies... Therefore, I want to be able to show subreports for each of these categories.
 
What you describe is not logical and won't happen with ACCESS. You can certainly insert more than one subreport into a report with different record sources and link them to the main report with Master/Child relationships, which is what I would suggest. Using a single subreport with multiple Source Objects is not possible. Add all the subreports to the main report and link them to the main report.
 
What you describe is not logical and won't happen with ACCESS. You can certainly insert more than one subreport into a report with different record sources and link them to the main report with Master/Child relationships, which is what I would suggest. Using a single subreport with multiple Source Objects is not possible. Add all the subreports to the main report and link them to the main report.
I'm sorry. My idea is add all the subreports to the main report and link them to the main report. I mean that all that subreports will have the same source.
 
OK. But you don't need any Select Case statments at all to do that. Just add them, link them and if there is no data in any of them you can set it not to show the subreport.
 
is this what you need.
view in Print Preview the report.
 

Attachments

Sorry. I have alreday seen your post. That's what I looking for. Thanks a lot.
 

Users who are viewing this thread

Back
Top Bottom