Getting a Report Title From a Table or Query

  • Thread starter Thread starter R Bolling
  • Start date Start date
R

R Bolling

I have a blank report where its recordsource is a table with 15 blank
records --only so it generates a worksheet type report with 15 rows
with lines, etc. It works fine. When I print the report from a form,
I can put the title from the form as such: forms![myform]![MyControl]
and that works fine too.

What I am trying to do is to be able to print all worksheets at one
time using a table or query as its recordsource for the report title.
Any tips will be greatly appreciated!

Thank you,

Robbie Bollinger
 
R said:
I have a blank report where its recordsource is a table with 15 blank
records --only so it generates a worksheet type report with 15 rows
with lines, etc. It works fine. When I print the report from a form,
I can put the title from the form as such: forms![myform]![MyControl]
and that works fine too.

What I am trying to do is to be able to print all worksheets at one
time using a table or query as its recordsource for the report title.

Create a table with a record for each title, then use a
query with both tables added. Make sure there is no join
line between the tables and add the title field to the field
list. Then you can use the query as the report's record
source.
 
R said:
I tried that, and the report row count increased (to the number of
titles there are). It needs to remain 10 blank rows so there are ten
blank rows in the report template.

Isn't there a way to go throught the table/query list of titles, and
print a report title for each new report?

I think I'm lost here. Could you post an example of how the
report is supposed to look along with the SQL of the
report's record source query.
--
Marsh
MVP [MS Access]


Marshall Barton said:
R said:
I have a blank report where its recordsource is a table with 15 blank
records --only so it generates a worksheet type report with 15 rows
with lines, etc. It works fine. When I print the report from a form,
I can put the title from the form as such: forms![myform]![MyControl]
and that works fine too.

What I am trying to do is to be able to print all worksheets at one
time using a table or query as its recordsource for the report title.

Create a table with a record for each title, then use a
query with both tables added. Make sure there is no join
line between the tables and add the title field to the field
list. Then you can use the query as the report's record
source.
 
Actually solved it by using the following code:

Public Sub PrintWorksheets()
Dim db As Database
Dim rsAreas As Recordset
Dim mArea As String 'Will hold "Area"

Set db = CurrentDb
'Open the Area Table as a SnapShot
Set rsAreas = db.OpenRecordset("qryArea", dbOpenSnapshot) 'Table with Titles

With rsAreas
'Go to the beginning of the snapshot
.MoveFirst
mArea = ""
Do Until .EOF
'Get the first "Area"
'The report needs to be open in order for the following loop to run
DoCmd.OpenReport "Worksheets", acPreview, "", "", acHidden
Reports!WorkSheets![AreaTitle] = .Fields(0)
DoCmd.OpenReport "WorkSheets", acNormal, "", "", acHidden
DoCmd.Close acReport, "WorkSheets"
.MoveNext
Loop
End With
End Sub


Marshall Barton said:
R said:
I have a blank report where its recordsource is a table with 15 blank
records --only so it generates a worksheet type report with 15 rows
with lines, etc. It works fine. When I print the report from a form,
I can put the title from the form as such: forms![myform]![MyControl]
and that works fine too.

What I am trying to do is to be able to print all worksheets at one
time using a table or query as its recordsource for the report title.

Create a table with a record for each title, then use a
query with both tables added. Make sure there is no join
line between the tables and add the title field to the field
list. Then you can use the query as the report's record
source.
 
Back
Top