473,385 Members | 1,396 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,385 software developers and data experts.

At what point is a Report added to the Reports collection?

At what point is a Form added to the Forms collection or a Report added
to the Report collection? I.e., listed as currently open. The reason
I ask is that I have a subreport for an exclusive separate condition
that may or may not have data. When it does have data its total needs
to be added to the final report total. I used a function like:

Public Function SubreportHasData(strReport As String, strSubReport As
String) As Boolean
Dim rptX As Report

SubreportHasData = False
For Each rptX In Reports
If rptX.Name = strReport Then
SubreportHasData =
Reports(strReport).Controls(strSubReport).Report.H asData
Exit For
End If
Next rptX
End Function

along with a totals ControlSource like:

=Format(Sum([QuotedJobTotal])+IIf(SubreportHasData("rptWorkInProgress","Subrep ortWorkInProgress"),Nz([txtTotSubQuotedJobTotal].[Value],0),0),"$#,##0.00")

which seemed to work. It also worked using
Reports("rptWorkInProgress").[Controls]("SubreportWorkInProgress").[Report].[HasData]
directly without a function call. This made me wonder about at what
precise point does it become safe to assume a Form or Report is in the
Forms or Reports collection.

Thanks,
James A. Fortune

Nov 20 '05 #1
3 2384
I don't know.
I never use

Reports("rptWorkInProgress").[Controls]("SubreportWorkInProgress").[Report].[HasData]

I always ensure that my Forms and Reports have modules (they don't
really have to have any code, just the HasModule property set to True).

I use the default instance of the Report as Object
as in
Report_WorkInProgress.HasData
(assuming WorkInProgress is the name of the sub report).
When the object is referenced in this way it is not necessary to travel
through its antecedents.

I'm aware that this will open the report if it is not already open. IMO
calling code with a reference to the subreport from the main report is
safe in this respect.

I also use this method when the report is not open:

Here are trivial examples:

Report_Fabrics.Visible = False 'don't show it
Debug.Print Report_Fabrics.HasData 'find out something bout it
Set Report_Fabrics = Nothing 'close it and release it
----
With Report_Fabrics
.Caption = "As of " & Date 'change public property
.Visible = True 'be sure it's open for viewing
End With
----
With Report_Fabrics
If .DoYouReallyWanna() Then ' run a public procedure
Nov 20 '05 #2
Certainly by the time controls are being evaluated, the form or report
should be in the collection.
But I'm mystified by why you're using such a roundabout approach.
You certainly don't need to loop through the Reports collection to find a
particular one - Me should work fine.
If you need to put your function in a standard module (where Me is
meaningless), you can pass a reference to the form as an argument, instead
of its name.
But why use the function at all?
Why not just put this in your ControlSource:
=Format(Sum([QuotedJobTotal])+IIf(Me.SubreportWorkInProgress.Form.HasData,Nz
([txtTotSubQuotedJobTotal].[Value],0),0),"$#,##0.00")


<ji********@compumarc.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
At what point is a Form added to the Forms collection or a Report added
to the Report collection? I.e., listed as currently open. The reason
I ask is that I have a subreport for an exclusive separate condition
that may or may not have data. When it does have data its total needs
to be added to the final report total. I used a function like:

Public Function SubreportHasData(strReport As String, strSubReport As
String) As Boolean
Dim rptX As Report

SubreportHasData = False
For Each rptX In Reports
If rptX.Name = strReport Then
SubreportHasData =
Reports(strReport).Controls(strSubReport).Report.H asData
Exit For
End If
Next rptX
End Function

along with a totals ControlSource like:

=Format(Sum([QuotedJobTotal])+IIf(SubreportHasData("rptWorkInProgress","Subr
eportWorkInProgress"),Nz([txtTotSubQuotedJobTotal].[Value],0),0),"$#,##0.00"
)
which seemed to work. It also worked using
Reports("rptWorkInProgress").[Controls]("SubreportWorkInProgress").[Report].
[HasData] directly without a function call. This made me wonder about at what
precise point does it become safe to assume a Form or Report is in the
Forms or Reports collection.

Thanks,
James A. Fortune

Nov 20 '05 #3
MacDermott wrote:
But why use the function at all?
Why not just put this in your ControlSource:
=Format(Sum([QuotedJobTotal])+IIf(Me.SubreportWorkInProgress.Form.HasData,Nz
([txtTotSubQuotedJobTotal].[Value],0),0),"$#,##0.00")


Ah. Why use the Reports Collection at all? Good point. I'm not
adding a field from a separate report so your suggestion looks
promising. I'll try it out. I'm still curious about the original
question though.

James A. Fortune

Nov 20 '05 #4

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

Similar topics

1
by: Mike Wiseley | last post by:
I would like to be able to loop through all the report objects in the database and show the recordsource for each and every report, even if the report is not actively open. If I know in advance of...
3
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have...
0
by: Henry | last post by:
I have written an ASP/VB.Net application via VS 2003 (Crystal V9) that uses MS Access 2000 as its database. I can export reports that have no linked sub reports for printing. However, I'm unable...
6
by: Bob Alston | last post by:
I am looking for Access reporting add-in that would be easy to use by end users. My key focus is on selection criteria. I am very happy with the Access report writer capabilities. As far as...
28
by: ryanhokanson | last post by:
I was just trying to get a list of all my reports along with their widths. I can't use the "Reports" collection because it only works on open reports. So I tried looking into the "AllReports"...
2
by: jmar | last post by:
I am updating a VB4.0 quote generation program to VB.net. The old program takes user inputs, performs calculations, saves the data to Access databases and uses Crystal Reports 5.0 to generate a...
5
by: jmar | last post by:
I posted a week ago and received one response. I'm looking for the opinion of several experienced .NET people before I proceed so I'm posting again. Sorry for the repost... I am updating a...
0
by: kamboj.shalabh | last post by:
Hi to all, Well, I am working on dotnet 2005 with crystal reports 10 and backend as sql server. I am facing a problem while loading a report. Actually the issue is, when I load report it takes...
7
by: Evanescent | last post by:
Hi guys, as the title suggests, I'm facing some problems with the report. I have a form (createInvoiceForm) whereby the user can enter the invoice's details and then click on the Add New Record...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.