?
Solved

access open report criteria - error!

Posted on 2012-03-19
9
Medium Priority
?
369 Views
Last Modified: 2012-03-19
I'm trying to open a report with the following statement:

DoCmd.OpenReport "CatWebWork2CommentR", acViewPreview, , "LinkToID = 526 AND CommentTypeID = 'CatWebWork'"

I get an error: "Data type mismatch in criteria expression", and access crashes.

What can be causing this?
0
Comment
Question by:etech0
[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
  • 5
  • 4
9 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 37738035
Is commentTypeID numeric?  You are passing a string literal.  

If CatWebWork is a variable or field on your form, and commenttypeID is numeric, try this syntax:

DoCmd.OpenReport "CatWebWork2CommentR", acViewPreview, , "LinkToID = 526 AND CommentTypeID = " & CatWebWork
0
 
LVL 10

Author Comment

by:etech0
ID: 37738049
It's a lookup field in the table. Am I supposed to pass the number, or the text?
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37738076
Look at the properties for CommentTypeID in the table's design view.

If it is a numeric field, you should pass a number.

If it is a text field, you should pass the text value.
0
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.

 
LVL 10

Author Comment

by:etech0
ID: 37738082
It's a number. I'll try passing a number.
0
 
LVL 10

Author Comment

by:etech0
ID: 37738093
Now I don't get the error, but it's not filtering by LinkToID!
0
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 37738109
Then the criteria are probably mutually exclusive - ie: you don't have any records in the recordsource where both of these are found:
          LinkToID = 526
          CommentTypeID  =  the number that you passed
0
 
LVL 10

Author Comment

by:etech0
ID: 37738116
Forget the last comment - it's working now.

Just give me a few minutes to test it out...
0
 
LVL 10

Author Closing Comment

by:etech0
ID: 37738129
That must have been it.

Thanks a million!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37738135
Glad to help out :)
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

801 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