I am using code to extract specific locations from a report based on a query that has no filtering on the location field, so the report contains all locations. my desire is to have one PDF file created for each location with the location number in the file name. I created a table that contains distinct location values named location_table which I am assigning the location to filter on in the report. The location field in both files is a 4 digit string value. The query to create the report works fine. the VB code to create multiple PDF's is:
Private Sub scan_sheets()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("SELECT Location FROM Location_table")
Do Until rst.EOF
docmd.OpenReport "Create Scan Sheets", acViewPreview, , "Location=" & rst("Location"), , acHidden
docmd.OutputTo acOutputReport, "Create Scan Sheets", acFormatPDF, "C:\Documents and Settings\dsingleton\My Documents\inventory\scan_sheets\location_" & rst("location FROM Location_table") & "_Review.pdf", True
docmd.Close acReport, "Create Scan Sheets"
Set rst = Nothing
When I run the procedure, I get run time error 3464, data type mismatch.