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
Solved

Open Report command with 2 filter

Posted on 2009-04-02
5
249 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
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

860 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