Solved

Open Report command with 2 filter

Posted on 2009-04-02
5
253 Views
Last Modified: 2012-05-06
Hi, I type below code in order open report after user click the button and the filter is Code and Exam year.
It has error message occured. "Mis match type run time error 13."

Thanks
DoCmd.OpenReport "ECVReport", acViewPreview, "ECVResult Report Query", "Code =""" & A & """" And "ExamYear =" & Chr(34) & Me!combExamYear & Chr(34)

Open in new window

0
Comment
Question by:mekofun
[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
5 Comments
 
LVL 3

Expert Comment

by:coleventures
ID: 24056926
DoCmd.OpenReport "ECVReport", acViewPreview, "ECVResult Report Query", "Code =""" & A & """" And "ExamYear =" & Chr(34) & Me!combExamYear & Chr(34)
 


Your error is with the """.  it should be "'" (double quote, single quote, double quote).
0
 
LVL 3

Expert Comment

by:coleventures
ID: 24056939
IGNORE my response.  I erred.  I am working on the correct syntax.  Sorry.
0
 
LVL 3

Expert Comment

by:coleventures
ID: 24056975
DoCmd.OpenReport "ECVReport", acViewPreview, "ECVResult Report Query", "Code =""" & A & """" And "ExamYear =" & Chr(34) & Me!combExamYear & Chr(34)


Now, if CODE is to be the literal A character and ExamYear is an integer/value and not  a string.
"Code = 'A' AND ExamYear = " & Me!combExamYear

If examyear is a string then you'd have to do this:
"Code = 'A' AND ExamYear = '" & Me!combExamYear & "'"

That would be = single double & Me!combExamYear & double single double.

Robert
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 500 total points
ID: 24057370
try this:

DoCmd.OpenReport "ECVReport", acViewPreview, "ECVResult Report Query", "[Code] = " & Chr(34)  & "A" & Chr(34) & " And [ExamYear] = " & Chr(34) & Me.combExamYear & Chr(34)

mx
0
 
LVL 28

Expert Comment

by:TextReport
ID: 24057488
I would use a variable for the where clause then it is easier to debug as you can inspect its value before trying to run the report.
If A is a variabl then the code below will work for you, if A is a literal then you need to put " around it.
Finally I have put a Debug.Print strWHERE so it will show the value of strWHERE in the Immediate Window. If you put a breakpoint (F9) on the OpenReport line you can inspect the value before trying to open the report.
Cheers, Andrew
Dim strWHERE as String
strWHERE = "Code =" & Chr(34) & A & Chr(34) & " And "ExamYear = " & Chr(34) & Me!combExamYear & Chr(34)
Debug.Print strWHERE
DoCmd.OpenReport "ECVReport", acViewPreview, "ECVResult Report Query", strWHERE
 

Open in new window

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 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