Solved

data type mismatch RTE 3464 on procedure to create multiple PDF files from 1 MS access report and name result files with location field value

Posted on 2011-03-02
5
512 Views
Last Modified: 2013-11-28
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"

  rst.MoveNext
Loop

rst.Close
Set rst = Nothing

End Sub

When I run the procedure, I get run time error 3464, data type mismatch.
Help!!


0
Comment
Question by:dave_sing
  • 3
  • 2
5 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 35017413
& rst("location FROM Location_table") &

should be
 & rst("location") &
0
 

Author Comment

by:dave_sing
ID: 35017677
I made the change and am still getting the same error message. when I press debug, the following line is highlighted.  docmd.OpenReport "Create Scan Sheets", acViewPreview, , "Location=" & rst("Location"), , acHidden

thanks
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 35017702
Assuming Location is a text field then that expression should use..

, "Location='" & rst("Location") &"'",
0
 

Author Comment

by:dave_sing
ID: 35017874
I made the change and also added & Chr(34) in line docmd.OpenReport "Create Scan Sheets", acViewPreview, , "Location=" & Chr(34) & rst("Location") & Chr(34), , acHidden and now the program works and generates reports, however it does not close the previous report when it starts on the next location and the screen fills up with the report. I thought that the Close ac report cmd would clear the screen. Anty advise.
thanks
0
 

Author Closing Comment

by:dave_sing
ID: 35018303
thanks for your assistance
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question