I'm very new to VBA and need help with a code. To summarize, I'm trying to use an existing parameter query to create a dataset. Then, I need to go through that dataset record by record, and export each record to an individual .pdf file. There will only be 10-20 records each month to do. I'm wondering if just running the query and doing each record manually is better:
Expand|Select|Wrap|Line Numbers
- ' Establish all the items I need.
- Dim dbs As DAO.Database
- 'After this I enter all elements below (omitted for space)
- ' Get user inputs for the start and end dates. Then convert these inputs from
- ' a string to a formatted date. These dates are used in the existing query.
- StartInput = InputBox("Select the start date in mm/dd/yyyy format.", "Select a Start Date")
- EndInput = InputBox("Select the end date in mm/dd/yyyy format.", "Select An End Date")
- StartDate = Format(StartInput, "Medium Date")
- EndDate = Format(EndInput, "Medium Date")
- ' Create the recordset from the pre-existing parameter query. I assume that
- ' after this, my dataset has the records I want to export to PDF
- Set dbs = CurrentDb()
- Set qdf = CurrentDb.QueryDefs("Analyst_Feedback")
- qdf.Parameters("Start_Date").Value = StartDate
- qdf.Parameters("End_Date").Value = EndDate
- Set rst = qdf.OpenRecordset
- ' Execute the Export Single Eval to PDF macro for each record. I don't know
- ' how to export each record individually from the dataset. The report called
- ' here normally exports from a query that selects the record I'm working on
- ' in a form.
- rst.MoveFirst
- Do Until rst.EOF
- DoCmd.OutputTo acOutputReport, "Feedback Evaluation Output - Master", "PDFFormat(*.pdf)", "", True, "", , acExportQualityPrint
- rst.MoveNext
- Loop
- End Sub