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!

Can you reference a caption of a report in Access 2000?

Status
Not open for further replies.

trustmefada

Technical User
Jun 26, 2007
14
0
0
US
I have to export reports into PDF format and I have to rename these PDF to their respective part numbers every time I print them to CutePDF writer. So...

Can you reference a caption of a report in Access 2000?
 
yes...

reports("ReportName").caption

--------------------
Procrastinate Now!
 
That didn't work. I copy pasted that into the caption box under the report properties and I tried with and without parantheses.

When I open the report up it queries a database and I enter a part number in the dialog box. The number I enter in the dialog box is what I want the PDF to be titled.

Any more suggestions?
 
I place a text box on a form. Then I refer to that text box in the report to obtain the title.
 
It seems to me that you are using a recordset to generate separate reports for each Part Number, so why not use the recordset to rename the reports?
 
TO SXSCHECH: How do you refer to the text box in the report?

TO REMOU: This is my setup that I didn't create.
There are 4 tables for the 4 pages of a report. Double-clicking on that report brings up a dialog box that wants you to enter a part number(which I have to enter multiple times, but not that big of a deal). Then it prints to the CutePDF writer and I am prompted to save the PDF. Everytime I would have to rename it from "ReportName" to the "Part Number I just entered".

Does that help any?
 
Your report is based on a query, it seems. You need some code. Let us say that the part numbers are stored in a table called tblParts. Copy the query that the report is based on as a back-up and get rid of the criteria line that asks for the part number. Let us say that this query is called qryPartReport. Create a module and add some code, like so:

Code:
Sub PrintReport Dim rs As DAO.Recordset
'Needs reference to Microsoft DAO 3.6 Object Library

Set rs=CurrentDB.OpenRecordset("tblParts")

'The query for the report
   qdf=CurrentDB.QueryDefs("qryPartReport")
   strSQLSave=qdf.SQL

Do While Not rs.EOF

   'Let us say that there is no where statement
   'in the SQL and that the PartNo field
   'is numeric
   strWhere = " Where PartNo=" & rs!PartNo

   qdf.SQL=strSaveSQL & strWhere
   
   
   'Let us say that the printer is set up
   DoCmd.OpenReport "rptPartNo", acViewNormal

   'Rename the report
   Name "C:\Docs\rptPartNo.pdf" As "C:\Docs\" & rs!PartNo & ".pdf"

   rs.MoveNext
Loop
'Put the query back the way it was
qdf.SQL=strSQLSave

This is just one approach. I am sure you will find others.




 
I don't think that would work because the report has 4 different queries to bring data from. Besides I have never used modules before.


Is it possible to run a code with a macro that is specifically made to rename the file to the Part Number used to generate the Report?
 
To reference the text box on the report.

Create a text box on your report and in the properties box Control Source do something like:

=[Forms]![frmMainSwitchboard].[Text48]

Remember that the form has to be open or an error will occur.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top