Solved

Open Report command with 2 filter

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server functions 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 Ac…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

810 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