473,382 Members | 1,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Can a report be programmatically moved to last page?

I can't move a multi-page report to the last record unless I keep the popup
form (that defined it's subreports) open.

DoCmd.OpenReport "rptStandard", acViewNormal
DoCmd.Close acForm, "frmReportOptions" <== popup form

This is the error I get when I try to move to the last page of the report
*after* closing the popup:

"This expression is typed incorectly, or is too complex to be evaluate...."

If I don't close the popup form -- but only minimize it -- I can navigate
all pages in the report no problem. The problem only happens if I close the
popup *before* moving to the last page of the report.

I think what is happening is that the subreports contained within the main
report have not loaded -- and the criteria they need to load are still
somehow linked to the popup form -- so until I move to the last page in the
report (with the popup open), the report still needs to load criteria from
the popup -- and therefore the subreorts on the other pages in the report
cannot evaluate their recordsource if the popup closes before they are
displayed.

I tried creating a public subroutine in rptStandard:

Public Sub GoToLast()
DoCmd.GoToRecord , , acLast
End Sub

and called it from the popup:

Report_rptStandard.GoToLast

Then I get this error:

Error Number 2499: You can't use the GoToRecord action or method on an
object in Design View.

Somehow I need to programmatically force the report to fully load (or move
it to the last page), while the popup is open -- then I should be able to
navigate the report with the popup closed.

If anyone has any suggestions, I would greatly appreciate it!

Nov 12 '05 #1
4 7018
I understand your Subreports to be in the Detail section, displayed for each
record in the underlying RecordSource. So, yes, it certainly makes sense
that each will be filled only when the corresponding detail record is
displayed.

I'd suggest you consider if there isn't some other way to provide the
criteria they need, other than the popup form (or make it just a normal
Form, so it won't display on top of the Report, and leave it open).

My normal use of Subreports is to display data in tables related to the
table in the main report, and I use the LinkMasterFields and LinkChildFields
to synchronize those. But, I can see that there might be times when you need
some additional criteria information.

If you are using Access 2002 or 2003, you could pass that information in the
OpenArgs argument of the Report; if earlier, set the information in a Public
variable instead of using a Control in a PopUp, or, as I suggested earlier,
use a regular Form instead and leave it open.

Larry Linson
Microsoft Access MVP
"deko" <dj****@hotmail.com> wrote in message
news:4T******************@newssvr25.news.prodigy.c om...
I can't move a multi-page report to the last record unless I keep the popup form (that defined it's subreports) open.

DoCmd.OpenReport "rptStandard", acViewNormal
DoCmd.Close acForm, "frmReportOptions" <== popup form

This is the error I get when I try to move to the last page of the report
*after* closing the popup:

"This expression is typed incorectly, or is too complex to be evaluate...."
If I don't close the popup form -- but only minimize it -- I can navigate
all pages in the report no problem. The problem only happens if I close the popup *before* moving to the last page of the report.

I think what is happening is that the subreports contained within the main
report have not loaded -- and the criteria they need to load are still
somehow linked to the popup form -- so until I move to the last page in the report (with the popup open), the report still needs to load criteria from the popup -- and therefore the subreorts on the other pages in the report
cannot evaluate their recordsource if the popup closes before they are
displayed.

I tried creating a public subroutine in rptStandard:

Public Sub GoToLast()
DoCmd.GoToRecord , , acLast
End Sub

and called it from the popup:

Report_rptStandard.GoToLast

Then I get this error:

Error Number 2499: You can't use the GoToRecord action or method on an
object in Design View.

Somehow I need to programmatically force the report to fully load (or move
it to the last page), while the popup is open -- then I should be able to
navigate the report with the popup closed.

If anyone has any suggestions, I would greatly appreciate it!

Nov 12 '05 #2
Thanks for the reply.

I got a bit creative with the subreports, as you'll see from the below code.
But this gives the user a lot of power in regard to what records, and what
information relating to those records, is included on the report.

I found a solution to the problem I described in my earlier post by adding
this line of code behind the popup form:

Form_frmTools.Visible = False

And I have this on the Close Event of the report:

DoCmd.Close acForm, "frmTools"

seems to work okay...

As for the code:

This is behind the main report:

Private Sub Report_Open(Cancel As Integer)
Dim ctl As Control
Dim strRo As String
Dim strRs As String
Dim strSearchQry As String
For Each ctl In Me.Report 'show only selected report options (i.e.
subreports)
If Left(ctl.Name, 1) = "R" Then
strRo = ctl.Name
If DCount(strRo, "tblOutput", strRo & " = True") = 0 Then
ctl.Visible = False
Else
ctl.Visible = True
End If
End If
Next ctl
'set recordsource based on user-criteria
If DLookup("RecSel", "tblOutput") = 1 Then strSearchQry =
DLookup("SearchQry", "tblOutput")
If DLookup("RecSel", "tblOutput") = 2 Then strSearchQry = "qry101"
strRs = ("SELECT [tblEntity].[LastName], [tblEntity].[Company],
[tblEntity].[FirstName], [tblEntity].[MiddleName], [tblEntity].[Prefix],
[tblEntity].[Suffix], [tblEntity].[Title], [tblEntity].[Entity_ID],
[tblEntity].[Cat_ID] FROM tblEntity WHERE [tblEntity].[Entity_ID] IN (SELECT
Entity_ID FROM " & strSearchQry & ")")
Me.RecordSource = strRs
End Sub

The below code is behind each subreport, with "strRs" specifying a different
SQL statement for each subreport in question (each subreport pulls data from
a different table).

Private Sub Report_Open(Cancel As Integer)
Static intCallCount As Long
Dim strSearchQry As String
Dim strRs As String
If intCallCount = 0 Then
If DLookup("RecSel", "tblOutput") = 1 Then strSearchQry =
DLookup("SearchQry", "tblOutput")
If DLookup("RecSel", "tblOutput") = 2 Then strSearchQry = "qry101"
strRs = ("SELECT [tblDocuments].[Document], [tblDocuments].[Doc_ID],
[tblDocuments].[Entity_ID] FROM tblDocuments WHERE
(([tblDocuments].[Entity_ID]) IN (SELECT Entity_ID FROM " & strSearchQry &
"))")
Me.RecordSource = strRs
intCallCount = intCallCount + 1
End If
End Sub
"Larry Linson" <bo*****@localhost.not> wrote in message
news:eQ******************@nwrddc02.gnilink.net...
I understand your Subreports to be in the Detail section, displayed for each record in the underlying RecordSource. So, yes, it certainly makes sense
that each will be filled only when the corresponding detail record is
displayed.

I'd suggest you consider if there isn't some other way to provide the
criteria they need, other than the popup form (or make it just a normal
Form, so it won't display on top of the Report, and leave it open).

My normal use of Subreports is to display data in tables related to the
table in the main report, and I use the LinkMasterFields and LinkChildFields to synchronize those. But, I can see that there might be times when you need some additional criteria information.

If you are using Access 2002 or 2003, you could pass that information in the OpenArgs argument of the Report; if earlier, set the information in a Public variable instead of using a Control in a PopUp, or, as I suggested earlier, use a regular Form instead and leave it open.

Larry Linson
Microsoft Access MVP
"deko" <dj****@hotmail.com> wrote in message
news:4T******************@newssvr25.news.prodigy.c om...
I can't move a multi-page report to the last record unless I keep the

popup
form (that defined it's subreports) open.

DoCmd.OpenReport "rptStandard", acViewNormal
DoCmd.Close acForm, "frmReportOptions" <== popup form

This is the error I get when I try to move to the last page of the report *after* closing the popup:

"This expression is typed incorectly, or is too complex to be

evaluate...."

If I don't close the popup form -- but only minimize it -- I can navigate all pages in the report no problem. The problem only happens if I close

the
popup *before* moving to the last page of the report.

I think what is happening is that the subreports contained within the main report have not loaded -- and the criteria they need to load are still
somehow linked to the popup form -- so until I move to the last page in

the
report (with the popup open), the report still needs to load criteria

from
the popup -- and therefore the subreorts on the other pages in the report cannot evaluate their recordsource if the popup closes before they are
displayed.

I tried creating a public subroutine in rptStandard:

Public Sub GoToLast()
DoCmd.GoToRecord , , acLast
End Sub

and called it from the popup:

Report_rptStandard.GoToLast

Then I get this error:

Error Number 2499: You can't use the GoToRecord action or method on an
object in Design View.

Somehow I need to programmatically force the report to fully load (or move it to the last page), while the popup is open -- then I should be able to navigate the report with the popup closed.

If anyone has any suggestions, I would greatly appreciate it!


Nov 12 '05 #3
>
I can't move a multi-page report to the last record unless I keep the popup
form (that defined it's subreports) open.


My solution (and I do this a lot) is that instead of closing the popup form, I
hide it (form.visible=false) and then I close it on the report's onclose event
(also on the onnodata if that's relevant).

HTH

Jan
Jan Stempel
Stempel Consulting
Nov 12 '05 #4
Deko,
Set <yourpopupform>.Visible = False as soon as you start running the
report, after the information has been entered. This keeps the popup
form open, but hidden.
In the .Close event of your report, issue <yourpopupform>.Close.
Cheers,
Doug

deko wrote:
I can't move a multi-page report to the last record unless I keep the popup
form (that defined it's subreports) open.

DoCmd.OpenReport "rptStandard", acViewNormal
DoCmd.Close acForm, "frmReportOptions" <== popup form

This is the error I get when I try to move to the last page of the report
*after* closing the popup:

"This expression is typed incorectly, or is too complex to be evaluate...."

If I don't close the popup form -- but only minimize it -- I can navigate
all pages in the report no problem. The problem only happens if I close the
popup *before* moving to the last page of the report.

I think what is happening is that the subreports contained within the main
report have not loaded -- and the criteria they need to load are still
somehow linked to the popup form -- so until I move to the last page in the
report (with the popup open), the report still needs to load criteria from
the popup -- and therefore the subreorts on the other pages in the report
cannot evaluate their recordsource if the popup closes before they are
displayed.

I tried creating a public subroutine in rptStandard:

Public Sub GoToLast()
DoCmd.GoToRecord , , acLast
End Sub

and called it from the popup:

Report_rptStandard.GoToLast

Then I get this error:

Error Number 2499: You can't use the GoToRecord action or method on an
object in Design View.

Somehow I need to programmatically force the report to fully load (or move
it to the last page), while the popup is open -- then I should be able to
navigate the report with the popup closed.

If anyone has any suggestions, I would greatly appreciate it!


Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: L Mehl | last post by:
Different users of the app will want or not want to see report footer ( appears as a separate page). I can make the section invisible with a DLookup of a Y or N value from a 'parameters' table ...
1
by: Phillip Lyles | last post by:
Hi Everybody, First of all if this has been asked 1000 times I am sorry. Is there a way in Access 2002 to open a report and have it go to the last page of the report and print just the last page? ...
3
by: Mike | last post by:
My boss insist on maintaing a paper copy of a patient waitng period report, utilizing a command button, how can I generate just the last page of the report? Thank you Mike
0
by: Greg | last post by:
Most suggestions on this topic recommend to use a page footer and make it visible only on the last page. My problem is that the footer is half of the height of a page which means the detail would...
1
by: James Barrett1234 | last post by:
I am attempting to print a disclaimer using the page footer, but only want this disclaimer to show up on the last page of the report. I can not use the report footer, because I need the diclaimer to...
13
by: Greg | last post by:
Most suggestions on this topic recommend to use a page footer and make it visible only on the last page. My problem is that the footer is half of the height of a page which means the detail would...
0
by: rinmanb70 | last post by:
I open a report with a button on a form and I'd like to have the report open to the last page. I tried using sendkeys and it works when I manually open the report from Reports on the msaccess...
3
by: BzyQ | last post by:
hi how do I, in vba code, open a report by DoCmd.OpenReport in acViewNormal mode and force it to print only the last page of it instead of the all pages ? BzyQ
0
by: rmurgia | last post by:
I am trying to create an Access report programmatically. So far I have been able to accomplish everything except the following: 1) I cannot determine the code to create a Page Footer Set...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.