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
515 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

726 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