[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
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
?
520 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
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…
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 …

656 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