Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To create Index sheet for report! 2

Status
Not open for further replies.

Fekri

Programmer
Jan 3, 2004
284
IR
Hi,

I have a report which has group header.

Now, I need to make another report like Index sheet as per the above report data.
It means, if in first report the different value in group header started in different pages, in the index sheet I need to have the following data:

Cities Page Number
Paris 1
London 13
Washington 15

thanks for any Idea...

Fekri
 
I haven't tried this, but you might add code to the Group On Print event that opens a table containing the 2 fields, add a new record and then pass it the city and page from the objects on the report
add a Module level variable to trap the City name:

dim strCity as string

then in the On Print event for the group add this

if strCity <> me!City then
dim db as dao.recordset, rst as dao.recordset
set db = currentdb
set rst = db.openrecordset("tblIndex")
with rst
.addnew
rst!City = Me!City
rst!Page = Me.Page
.update
End with
set rst = nothing
set db = nothing
strCity = me!City
end if

PaulF
 
okay, I just tried it in a test database and noticed the following.

I had a problem with Me!City and had to reference the control instead of the field Me.txtCity

It populated the table okay, but it has to go though the entire report, page by page to capture all of the data. This is not a problem if you entend to print the report to the printer or to a file. Also you need to run a query to delete any existing data in the table, use the Report's Open event for this.

Private Sub Report_Open(Cancel As Integer)
DoCmd.SetWarnings False
DoCmd.RunSQL ("Delete * From tblIndex")
DoCmd.SetWarnings True
End Sub

PaulF
 
Thanks Paulf

I got error in "set db = currentdb"
So I understand that I have to change the following line:

"dim db as dao.recordset" to "dim db as database"

and then works perfect.

Thanks a lot
Fekri
 
One more request,

This method when will complete if the report is printed or previewed all the pages.
But is there a way to complete the table, without preview or print the report?

Thanks
Fekri
 
not to my knowledge, but you could open it hidden at any time to populate the table. You'd have to change the code so that it only populated the table when you wanted it to and not every time. You could do that by passing an Open Argument like this:

DoCmd.OpenReport "rptName", acViewPreview, , , acHidden, "RunCode"


then add another If statement to the code such as this

If Me.OpenArgs = "RunCode" Then
'Run your Code

End If

To run the report without populating the table, don't pass any open argument with the OpenReport statemewnt.

PaulF
 
Thanks for your usefull help

Fekri
 
Hi both, i finally found in this thread what i wanted for making a table of contents. But i am using access 2000, so i don't have the great possibility of hidden reports. Anyway, what i haven't achieved is to complete the table often previewing the report, i have tried several ways like Docmd.GotoPage. No result. Is there a way, for ugly it be, for making that?

Thanks for looking.
 
Hi both, i finally found in this thread what i wanted for making a table of contents. But i am using access 2000, so i don't have the great possibility of hidden reports. Anyway, what i haven't achieved is to complete the table often previewing the report, i have tried several ways like Docmd.GotoPage. No result. Is there a way, for ugly it be, for making that?

Thanks for looking.
 
Why not use OutputTo and send it to a file, and then erase the file. You could use a PopUp form to let the user know you are taking some time to create an index.

PaulF
 
PaulF,

I want to thank you for your post. I have been looking for this form of answer for what I was trying to do for my recipe database.
 
PaulF, excuse the delay on the reply. I have made that and i have what i wanted. Thanks for this valuable help.
 
PaulF, excuse the delay on the reply. I have made that and i have what i wanted. Thanks for the help.
 
Hi again,
I started this thread long time ago.

actually, I did it perfectly on that time, but now after long time when I want to do it again I couldn't.

I don't know why the report which should open as hidden, will open in normal view in back of index report.

so, like this only the data of first page will print in report index!!!
I', still using office 2003 and nothing changed but I don't know how I couldn't!!!

thanks for any help..
Ali
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top