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

Working with subreports in a Report

194 100+
I made a report in design view by importing 4 sub reports. these sub reports based on 4 different queries. each query's search criteria is dateField. if i run the report i have to enter dateField's value 4 times. is there any way to enter date only one time to run 4 queries? please tell me. thank u.
Oct 10 '07 #1
23 4044
nico5038
3,080 Expert 2GB
Best to create a "frmReports" with a field "txtSelectionDate" and a button to start the report (Just follow the button wizard)

Now use in the report queries for the datefield the criteria:
forms!frmReports!txtSelectionDate

Just make sure that the field holds a valid date before pressing the button !

Nic;o)
Oct 10 '07 #2
mfaisalwarraich
194 100+
it really worked :) thanks a lot my friend :) im grateful to you.

well here is another question for you :) i just dont wana let u run from me. get ready ok.

is it possible that i can make reports dynamic format. means if a reports has 50 records then this report should not overlap with other report on the page. after the records of first report finished then other report should start. what should i do now?

and if any report does not have any value then "No Records Found" or "Nil" can be written on that place with heading of that report.
Oct 11 '07 #3
nico5038
3,080 Expert 2GB
Best to post two new questions. TheScripts likes to have one question per thread, thus it's easier for other people (e.g. searching a solution with Google) to find and read the info they are looking for. Just send a PM (Personal message) with the URL's of these new threads when you get no response from our experts and I'll "jump in".

Nic;o)
Oct 11 '07 #4
mfaisalwarraich
194 100+
hi, i acted upon nico's advise and search a lot over the web to find out my solution for this problem. surprisingly :) i found solution by default.

but there is one problem that im still facing and failed to get solution over the web. if there is no data in report then a text box should appear on the same report with the value "No Records Found".

i found solution by putting some code into OnNoData event of the report and its working but only working when i open the report alone. when i open this report as a subreport in other report (made in design view), this report is not even visible. i failed to understand why. i tried my level best but i did not find any solution. so im requesting you again to please tell me how i would write a value into a text box if there is no record found in a subreport. thank u
Oct 13 '07 #5
nico5038
3,080 Expert 2GB
This can be done in the code of the mainreport by testing or the subreport's query will return records and then fill (or make visible) a label on the mainreport.

Nic;o)
Oct 13 '07 #6
mfaisalwarraich
194 100+
thank u for ur quick reply. but as i told u i tried my best by putting some conditions on the main report. but if u would please tell me how i can do this with some code.

thank u.
Oct 13 '07 #7
nico5038
3,080 Expert 2GB
You can use the RecordsetClone method. Set a DAO.recordset variable based on the Reports!YourReportName!YourSubReportName.Report.Re cordsetClone.
Next test for the EOF and BOF being true and the subreport will be empty.

Nic;o)
Oct 13 '07 #8
mfaisalwarraich
194 100+
:) what i can say now? im not an expert friend :). i haven't used DAO.Recordset before :) but i read about it on the web. really it is difficult for me to get the rights syntax. however, i made some effort to solve my problem here how i am doing :)
but im getting error on the second line. txtNoData is a text box with its visible property set to no.

1. Private Sub Report_Open(Cancel As Integer)
2. Dim rs As DAO.Recordset
3. Set rs = Reports!mainReport!subReport.Report.RecordsetClone

4. If (rs.EOF And rs.BOF) = True Then
5. Me!txtnoData.Visible = True
6. Me![txtNoData] = "No Records Found"
7. End If
8. End Sub

here is what im using on the ON OPEN event of the main report. please tell me where im making a mistake. as i told u above i got error at line number 2. please tell me how to solve this problem. thank u.
Oct 13 '07 #9
nico5038
3,080 Expert 2GB
It would help when you would post the error message, but I guess that the needed DAO library reference isn't set.
Open in VBA mode Tools/References. Remove a checkmark when you find a reference to "Microsoft Active Data Object" and make sure a reference to "Micorsoft DAO version 3.##" is checked. (Scrolllllll doooown)

Nic;o)
Oct 13 '07 #10
mfaisalwarraich
194 100+
thank u once again nico. i setup the required object library "Microsoft DAO 3.6 Object Library". is it the required one? and i am still receiving the following runtime error

Run-time error '2455':

You entered and expression that has an invalid reference to the property Form/Report

The following is the code which is set on On Open Event of Main Report.

1. Private Sub Report_Open(Cancel As Integer)
2. Dim rs As DAO.Recordset
3. Set rs = Reports!rpt_DailyState!rpt_BroughtInDead.Report.Re cordsetClone

4. If (rs.EOF And rs.BOF) = True Then

5. Me![txtNoData] = "No Records Found"
6. End If

7. End Sub

3rd line is highlighted in yellow in the code window.

rpt_DailyState is mainReport
rpt_BroughtInDead is subreport of this mainReport.

is the 3rd line has the right syntax to call a subreport in a report?
please guide me. thank u
Oct 14 '07 #11
MMcCarthy
14,534 Expert Mod 8TB
Move your code to the On Format event of the Report rather than the On Open event.
Oct 14 '07 #12
mfaisalwarraich
194 100+
ok i put the code in or format event of the main report and now getting this error:

Run-time error '2465':

Application-defined or object-defined error.

what should i do now?
Oct 14 '07 #13
MMcCarthy
14,534 Expert Mod 8TB
ok i put the code in or format event of the main report and now getting this error:

Run-time error '2465':

Application-defined or object-defined error.

what should i do now?
What line of code is it stopping at?
Oct 14 '07 #14
mfaisalwarraich
194 100+
What line of code is it stopping at?
Here is the code:

1. Private Sub Report_Open(Cancel As Integer)
2. Dim rs As DAO.Recordset
3. Set rs = Reports!rpt_DailyState!rpt_BroughtInDead.Report.Re cordsetClone

4. If (rs.EOF And rs.BOF) = True Then

5. Me![txtNoData] = "No Records Found"
6. End If

7. End Sub

it is stopping at the 3rd line. and the error is: Application-define or Object-defined Error.
Oct 14 '07 #15
MMcCarthy
14,534 Expert Mod 8TB
Try this instead
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2. Dim rs As DAO.Recordset
  3.  
  4.     Set rs = Reports!rpt_DailyState!rpt_BroughtInDead.Report.RecordsetClone
  5.  
  6.     If (rs.EOF And rs.BOF) = True Then
  7.  
  8.         Me![txtNoData] = "No Records Found"
  9.     End If
  10.  
  11. End Sub
  12.  
RecordsetClone is all one work. It is being broken up by the tag editor.
Oct 14 '07 #16
mfaisalwarraich
194 100+
Try this instead
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2. Dim rs As DAO.Recordset
  3.  
  4.     Set rs = Reports!rpt_DailyState!rpt_BroughtInDead.Report.RecordsetClone
  5.  
  6.     If (rs.EOF And rs.BOF) = True Then
  7.  
  8.         Me![txtNoData] = "No Records Found"
  9.     End If
  10.  
  11. End Sub
  12.  
RecordsetClone is all one work. It is being broken up by the tag editor.
thank u for an instant reply. but regretfully submitted that i got the same error at the same line.
Oct 14 '07 #17
nico5038
3,080 Expert 2GB
Hmm, guess we need to see the .mdb to detect the problem. Can you make an "insensitive" testversion and post the zipped .mdb here as attachment ?

Nic;o)
Oct 14 '07 #18
MMcCarthy
14,534 Expert Mod 8TB
Hmm, guess we need to see the .mdb to detect the problem. Can you make an "insensitive" testversion and post the zipped .mdb here as attachment ?

Nic;o)
To attach it, you will need to post first and then edit the post to add the attachment.
Oct 14 '07 #19
mfaisalwarraich
194 100+
To attach it, you will need to post first and then edit the post to add the attachment.
sorry i cant make it 97.7kb file. what should i do now? is there any other way to upload this MDB???
Oct 15 '07 #20
mfaisalwarraich
194 100+
ok here is the testVersion. i made one table, 3 queries and 3 reports based on this table.

condition field has 2 separate values ("Normal" and "Dead in Hospital"). In search critera of 2 queries i found the records. but at third query named qry_BroughtInDead i did not find any record. after making queries i made three report based on these 3 queries. and then i added these three reports into a main report called rpt_DailyState. i what i want is if there is no result in "rpt_BroughtInDead", a text box should have the value "No Records Found" on the main report (rpt_DailyState). now please tell me where im doing mistake. thank u
Attached Files
File Type: zip testVersion.zip (20.6 KB, 126 views)
Oct 15 '07 #21
nico5038
3,080 Expert 2GB
OK, looks indeed that the RecordsetClone won't work :-(
But as your report isn't linked to the main report, you can use the report query to get the number of records like:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2.    Dim rs As DAO.Recordset
  3.  
  4.          Set rs = CurrentDb.OpenRecordset("qry_BroughtInDead")
  5.  
  6.          If rs.EOF And rs.BOF Then
  7.  
  8.               Me![txtNoData] = "No Records Found"
  9.  
  10.          End If
  11.  
  12. End Sub
  13.  
Make sure that the field [txtNoData] is placed in the Details section and that the "Visible" property is set to "Yes", otherwise it won't show.

Nic;o)
Oct 15 '07 #22
mfaisalwarraich
194 100+
OK, looks indeed that the RecordsetClone won't work :-(
But as your report isn't linked to the main report, you can use the report query to get the number of records like:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2.    Dim rs As DAO.Recordset
  3.  
  4.          Set rs = CurrentDb.OpenRecordset("qry_BroughtInDead")
  5.  
  6.          If rs.EOF And rs.BOF Then
  7.  
  8.               Me![txtNoData] = "No Records Found"
  9.  
  10.          End If
  11.  
  12. End Sub
  13.  
Make sure that the field [txtNoData] is placed in the Details section and that the "Visible" property is set to "Yes", otherwise it won't show.

Nic;o)
thank u nico its really working in testVersion. but when i copy that code into my original database i presented with another error "Too Few Parameters. Expected 1." im sorry i know its my mistake. i was not aware of the consequences not to include a search form which is working as search critera for these queries. here is my testVersion file again which has "Too Few Parameters" error. please help me out. thank u
Attached Files
File Type: zip testVersion.zip (29.2 KB, 140 views)
Oct 16 '07 #23
nico5038
3,080 Expert 2GB
This message is cause by an erroneous fieldname.
Check all fields to appear in the table/query !

Nic;o)
Oct 16 '07 #24

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Anne | last post by:
I have a report containing multiple subreports (approximately 37 subreports) that are based on individual queries. The query calls to only display the subreport if there is valid data in the table...
1
by: Don Sealer | last post by:
I have a report that includes 5 different subreports. I'd like to be able to open this report using a date function (Start Date and End Date). I'd like all five subreports to show the data from...
0
by: Don Sealer | last post by:
I have a report that includes 5 different subreports. I'd like to be able to open this report using a date function (Start Date and End Date). I'd like all five subreports to show the data from...
2
by: AccessAl | last post by:
:confused: I have inheritted a system with reports that were probably written by a novice access programmer. My problem is a report with a dozen subreports in them. I had to add another subreport...
1
by: David | last post by:
Folks, I have four subreports in a report in the detail section. I suppose I could move them to the footer of the report. Anyway, if any of them have data, I want the main report to force a...
7
by: baool | last post by:
I have a report that keeps track of sales by company for any given month within a year. I am using two subreports embedded within a report to produce 2006 (one subreport) and 2007 (the other...
0
by: billygotee | last post by:
Hi, I'm having an issue with VS .NET 2k5. I have a master report that is the parent of several subreports (the report got too big to keep it all in the same report). For a while this worked...
1
by: MartinaN | last post by:
Hello, I have a MS Access 2000 question. I created a main report that consists of different subreports in the Detail section. I have a couple of queries that create tables for certain cities (the...
6
by: Brett Barry: Go Get Geek! | last post by:
Hello, I have a main report with a Record Source, a DateToday table, that has the current Month and Year. I have about 60 queries, each pulling different data via ODBC, that I am creating...
10
by: glenfernandez | last post by:
HI there, Need a little help with the reporting component of my MS Access 2002 project and would appreciate any insight / help from the experts. Please bear with me as I am still learning Access...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.