Solved

Open Report command with 2 filter

Posted on 2009-04-02
5
243 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 - Access MVP) 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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 …

747 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

12 Experts available now in Live!

Get 1:1 Help Now