[AccessD] Access VBA code (loop) needed
Stuart McLachlan
stuart at lexacorp.com.pg
Fri Oct 25 17:04:52 CDT 2024
I don't understand "no DAO in the library". Do you mean the refence to
Microsofto Office 1x.0 Access database Object Library
is not selected in the VBE Tools- References. If so, select it.
How are you creating the PDF?
Are you using something like:
DoCmd.OutputTo acOutputReport, strReportName, acFormatPDF, ReportFolder() &
strFileName
I'd do something like this:
Create a function
STATIC FUNCTION EmplName(sName AS STRING) As STRING
Dim strStore As STRING
If sName <> "" Then strStorre = strsName
EmplName = strStore
END FUNCTION
Set the Report source to a query that has EMployeeName = EMplName()
Step through a recordset/list of EmployeeNames.
If you REALLY don't have DAO, populate a listbox with the EmployeeNames and step
through it)
For Each .....
EmplName(!EmployeeName)
strFilename = EMplName()
Docmd.Output......
Next
On 25 Oct 2024 at 21:12, DENISE A DECENSO via AccessD wrote:
> Hello, I have a simple access database used only to create and export reports as pdf files.
> It produces a single large multi-page report for many employers (each having its own page) and I would like to save each employer as its own separate pdf, with the employer as the file name. Currently it is being done manually print/save 1 at a time.
>
> Here is the relevant information:
> the data source to be output to pdf is a report named [FundingReport]
> the critical field in the report is [EmployerName]. The report is grouped and sorted on that field.
> the report has a natural page break with the content for each [EmployerName].
> there are about 550 pages (employers) in total.
>
> the goal is to output to pdf a file for each Employer report with that [EmployerName] as the file name.
>
> Other notes:
> Using Access 2016. There is no "DAO" in the library, so any code I've found that has DAO is failing.
>
> I appreciate any help you can give me.
>
> Thank you,
> Denise DeCenso
>
>
> Disclaimer:
>
>
> This electronic message and its contents and attachments contain information from Sentara Health and is confidential or otherwise protected from disclosure. The information is intended to be for the addressee only.
>
> If you are not the addressee, any disclosure, copy, distribution or use of the contents of this message is prohibited. If you have received this electronic message in error, please notify us immediately and destroy the original message and all copies.
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
More information about the AccessD
mailing list