Accessing Control Value

gowans07

Registered User.
Local time
Today, 12:10
Joined
Sep 27, 2011
Messages
36
I have a report which has a subreport located within a group header, i'm trying to save the report as a .pdf via vba

The name of report when saved will use some of the values located within the subreport. How can i access these values, or atleast move the recordset on by one when generating the filename?
Hope i've explained clearly


Thanks
TG
 
I believe you are using access 2010. Best to put your version at start of post as this can make a big difference on some issues.

Here is an example of Report saving in 2010.
Code:
DoCmd.OpenReport "RptStatementNewStyle", acViewPreview, , strWhere
    DoCmd.OutputTo acOutputReport, "RptStatementNewStyle", acFormatPDF, "W:\Attachments\" & FullName & " Loan " & LoanRef & " Loan Statement " & TeamMember & ".pdf", 0, , , acExportQualityPrint
Earlier in your code, you create the strWhere variable.

You can also build up your file name. In this example the file name includes the Full Name, Loan Reference and User Name.
This data can be collected in a number of ways but if your code is on a Form then you can use.
Code:
MyVariable = Me.ControlName
 
Since the subreport would contain multiple records, how would you determine which value to use? If you know how to find the "unique" value you want, you can use a DLookup() to find it and then concatenate the lookup value into the file name.
 
I believe you are using access 2010. Best to put your version at start of post as this can make a big difference on some issues.

Here is an example of Report saving in 2010.
Code:
DoCmd.OpenReport "RptStatementNewStyle", acViewPreview, , strWhere
    DoCmd.OutputTo acOutputReport, "RptStatementNewStyle", acFormatPDF, "W:\Attachments\" & FullName & " Loan " & LoanRef & " Loan Statement " & TeamMember & ".pdf", 0, , , acExportQualityPrint
Earlier in your code, you create the strWhere variable.

You can also build up your file name. In this example the file name includes the Full Name, Loan Reference and User Name.
This data can be collected in a number of ways but if your code is on a Form then you can use.
Code:
MyVariable = Me.ControlName

Thanks for the reply, should of mentioned which version i am using.
On saving as pdf code above, if the report is already open and i use the docmd.openreport will this create an error? Also what does the where statement refer too? Tried a variation of this but get the error: This action can't be carried out while proccessing a form or a report event.

I've placed the save code in the report_close i presume this is a reason for the error.
 
Since the subreport would contain multiple records, how would you determine which value to use? If you know how to find the "unique" value you want, you can use a DLookup() to find it and then concatenate the lookup value into the file name.

Exactly what is trying to explain, thank you! Will give it a go :)
 
If you were to have a situation where a Report (not a Form) opened and then you wished to reopen the same report but have certain data displayed or not display related to some value you can see on the report then you could read the value (refer earlier posts regarding this), save some key data to a Public Variable (TempVar if 2010).
Then have the code close the Report and reopen same.

On the report Open Event or Load (?) have code that checks if the TempVar exists and if so, use this to efect the report so you have what you are looking for.

Not sure why you would want to change a report.

Normal usage is to open a Form, do something and then have a Report Open how you want it to.
 

Users who are viewing this thread

Back
Top Bottom