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
510 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

746 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now