?
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
Medium Priority
?
517 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 2000 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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 …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

762 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