Cannot view report - error 2501 (1 Viewer)

JohnPapa

Registered User.
Local time
Today, 15:30
Joined
Aug 15, 2010
Messages
954
I am running A365 as a frontend to SQL Server
I have a form called "frm3" which is made up of 6 subforms

1698054777277.png


I have created a report "rpt3" which shows the same data and is made up of 6 subreports
1698054953627.png


The 6 subreports use the same queries as the 6 subforms

When I try to call rpt3 from frm3 I get error 2501

1698054953462.png


I call rpt3 using
DoCmd.OpenReport "rpt3", acViewPreview
 

Attachments

  • 1698054996095.png
    1698054996095.png
    5.8 KB · Views: 41

JohnPapa

Registered User.
Local time
Today, 15:30
Joined
Aug 15, 2010
Messages
954
If it helps the report appears if I use

Code:
DoCmd.OpenReport "rpt3", acViewReport

But this does not show the report buttons such as Print, Export to PDF etc.

Also, I get error 2501, if I call

Code:
DoCmd.OpenReport "rpt3", acViewPreview

from other forms, not just form "frm3"
 

bob fitz

AWF VIP
Local time
Today, 13:30
Joined
May 23, 2011
Messages
4,727
can you open other reports in Preview
 

bob fitz

AWF VIP
Local time
Today, 13:30
Joined
May 23, 2011
Messages
4,727
Does the report open ok if you use:
DoCmd.OpenReport "rpt3", acViewPreview
in the Immediate Window
 

JohnPapa

Registered User.
Local time
Today, 15:30
Joined
Aug 15, 2010
Messages
954
I moved the subReports from the Report Header to the Detail section and it works.

I vaguely remember having a similar problem which was solved after the subreports were moved to the Detail section
 

JohnPapa

Registered User.
Local time
Today, 15:30
Joined
Aug 15, 2010
Messages
954
Perhaps someone can provide a technical explanation. Is it a bug?
 

LarryE

Active member
Local time
Today, 05:30
Joined
Aug 18, 2021
Messages
591
Subreports usually have Master/Child links established, but I don't think they work properly if the subreport is in the header or footer.
 

JohnPapa

Registered User.
Local time
Today, 15:30
Joined
Aug 15, 2010
Messages
954
So most probably it is a bug, one that may take a lot of time to find a solution!!!
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:30
Joined
Feb 28, 2001
Messages
27,186
I'm going to post a link that gives detailed issues that could lead to this error. The link involves a product that I do not know and there neither recommend in favor or warn against, but there are some nuggets of wisdom in the article independent of the product.


This should NOT be construed as recommending any product.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:30
Joined
Feb 19, 2002
Messages
43,275
Perhaps someone can provide a technical explanation. Is it a bug?
it likely has to do with the order in which events run. At the time the report header is being formatted, something required does not yet exist. Since subforms/subreports open before the main form/report, the underlying code might only open subforms/subreports that are in the main object's detail section. Therefore when the header is formatted, any subreports have not been opened and so don't exist.

I have only seen the 2501 error when an event runs the OpenReport method and the report has no data and so closes. This isn't mentioned in the list. But all my code that opens reports traps for this error.
 

LarryE

Active member
Local time
Today, 05:30
Joined
Aug 18, 2021
Messages
591
So most probably it is a bug, one that may take a lot of time to find a solution!!!
No I dodn't think its a bug. Subreports need the Master/Child links to work properly and only the Detail section or Groups have them. And as Pat said, the subreport opens first so it needs those records in the Detail section or a Group section.
 

JohnPapa

Registered User.
Local time
Today, 15:30
Joined
Aug 15, 2010
Messages
954
I'm going to post a link that gives detailed issues that could lead to this error. The link involves a product that I do not know and there neither recommend in favor or warn against, but there are some nuggets of wisdom in the article independent of the product.


This should NOT be construed as recommending any product.
I came across this article in my quest for a solution and did try a few of the suggestions.
 

JohnPapa

Registered User.
Local time
Today, 15:30
Joined
Aug 15, 2010
Messages
954
No I dodn't think its a bug. Subreports need the Master/Child links to work properly and only the Detail section or Groups have them. And as Pat said, the subreport opens first so it needs those records in the Detail section or a Group section.
Thanks for your input. Why do you say that subreports need the Master/Child link to work? I did not find anything in the documentation regarding this and as you can see, in practice, there is no need for the link.
 

Minty

AWF VIP
Local time
Today, 13:30
Joined
Jul 26, 2013
Messages
10,371
I think the issues is that without any data in the detail section the report won't attempt to load any subforms.
I suspect you can put sub reports in the header as long as you have some data in the detail section.
 

Users who are viewing this thread

Top Bottom